src/Builder4/WindowRooView.bjs
authorAlan <alan@roojs.com>
Thu, 18 Aug 2022 10:35:29 +0000 (18:35 +0800)
committerAlan <alan@roojs.com>
Thu, 18 Aug 2022 10:35:29 +0000 (18:35 +0800)
src/Builder4/WindowRooView.vala

src/Builder4/WindowRooView.bjs
src/Builder4/WindowRooView.vala

index 42023c5..11d4f37 100644 (file)
       {
        "$ xns" : "Gtk",
        "* pack" : "append_page,_this.label_code.el",
-       "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
+       "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
        "int spacing" : 0,
-       "xtype" : "Box"
-      },
-      {
-       "$ xns" : "Gtk",
-       "* pack" : "append_page,_this.label_code.el",
        "items" : [
         {
-         "# JsRender.Node? node_selected" : "null",
-         "# bool button_is_pressed" : false,
-         "# bool key_is_pressed" : false,
-         "# bool loading" : true,
-         "# int editable_start_pos" : "-1",
-         "$ string prop_selected" : "\"\"",
          "$ xns" : "Gtk",
-         "* init" : [
-          "{",
-          "   ",
-          "   ",
-          "    var description =   Pango.FontDescription.from_string(\"monospace\");",
-          "    description.set_size(8000);",
-          "    this.el.override_font(description);",
-          "",
-          "    this.loading = true;",
-          "    //var buf = this.el.get_buffer();",
-          "    //buf.notify.connect(this.onCursorChanged);",
-          "  ",
-          "  ",
-          "    var attrs = new Gtk.SourceMarkAttributes();",
-          "    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 Gtk.SourceMarkAttributes();",
-          "    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 Gtk.SourceMarkAttributes();",
-          "    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 Gtk.SourceMarkAttributes();",
-          "    var  grey =   Gdk.RGBA();",
-          "    grey.parse ( \"#ccc\");",
-          "    gattrs.set_background ( grey);",
-          " ",
-          "    ",
-          "    this.el.set_mark_attributes (\"grey\", gattrs, 1);",
-          "    ",
-          "    ",
-          "    ",
-          "    ",
-          "    ",
-          "    ",
-          "}",
-          " "
-         ],
-         "* pack" : "add",
-         "gboolean editable" : false,
-         "gboolean show_line_marks" : true,
-         "gboolean show_line_numbers" : true,
-         "id" : "sourceview",
+         "bool vexpand" : true,
          "items" : [
           {
+           "# JsRender.Node? node_selected" : "null",
+           "# bool button_is_pressed" : false,
+           "# bool key_is_pressed" : false,
+           "# bool loading" : true,
+           "# int editable_start_pos" : "-1",
+           "$ string prop_selected" : "\"\"",
            "$ xns" : "Gtk",
-           "* pack" : "set_buffer",
-           "bool dirty" : false,
-           "id" : "buffer",
-           "int error_line" : "-1",
+           "* init" : [
+            "{",
+            "   ",
+            "   ",
+            "    var description =   Pango.FontDescription.from_string(\"monospace\");",
+            "    description.set_size(8000);",
+            "    this.el.override_font(description);",
+            "",
+            "    this.loading = true;",
+            "    //var buf = this.el.get_buffer();",
+            "    //buf.notify.connect(this.onCursorChanged);",
+            "  ",
+            "  ",
+            "    var attrs = new Gtk.SourceMarkAttributes();",
+            "    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 Gtk.SourceMarkAttributes();",
+            "    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 Gtk.SourceMarkAttributes();",
+            "    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 Gtk.SourceMarkAttributes();",
+            "    var  grey =   Gdk.RGBA();",
+            "    grey.parse ( \"#ccc\");",
+            "    gattrs.set_background ( grey);",
+            " ",
+            "    ",
+            "    this.el.set_mark_attributes (\"grey\", gattrs, 1);",
+            "    ",
+            "    ",
+            "    ",
+            "    ",
+            "    ",
+            "    ",
+            "}",
+            " "
+           ],
+           "* pack" : "add",
+           "gboolean editable" : false,
+           "gboolean show_line_marks" : true,
+           "gboolean show_line_numbers" : true,
+           "id" : "sourceview",
+           "items" : [
+            {
+             "$ xns" : "Gtk",
+             "* pack" : "set_buffer",
+             "bool dirty" : false,
+             "id" : "buffer",
+             "int error_line" : "-1",
+             "listeners" : {
+              "changed" : [
+               " () => {",
+               " ",
+               "",
+               "    // check syntax??",
+               "    // ??needed..??",
+               "   // _this.save_button.el.sensitive = true;",
+               "    ///?? has changed occured during loading?",
+               "    ",
+               "    // only trigger this if ",
+               "    ",
+               "    ",
+               "    ",
+               "    ",
+               "    if (_this.sourceview.loading) {",
+               "\t\treturn;",
+               "\t}",
+               "\t",
+               "",
+               "\t",
+               "    print(\"- PREVIEW EDITOR CHANGED--\");",
+               "",
+               "    this.dirty = true;  ",
+               "    this.checkSyntax(); // this calls backs and highlights errors.. in theory...  ",
+               "",
+               "",
+               "",
+               "\tif (!_this.sourceview.button_is_pressed && !_this.sourceview.key_is_pressed) {",
+               "\t\tprint(\"button or key not pressed to generate change?!\\n\");",
+               "\t\treturn;",
+               "\t}",
+               "\t\t",
+               "    ",
+               "\t// what are we editing??",
+               "\tif (null == _this.sourceview.node_selected || _this.sourceview.prop_selected.length  < 1) {",
+               "\t\treturn;",
+               "\t}",
+               "\t",
+               "\t// find the colon on the first line...",
+               "\t",
+               "\tif (_this.sourceview.editable_start_pos > -1) {",
+               "\t\t",
+               "\t\tvar buf = (Gtk.SourceBuffer)_this.sourceview.el.get_buffer();",
+               "\t\t",
+               "        //print(\"cursor changed : %d\\n\", buf.cursor_position);",
+               "        Gtk.TextIter spos,epos;",
+               "        buf.get_iter_at_offset(out spos, _this.sourceview.editable_start_pos);",
+               "        buf.get_iter_at_offset(out epos, _this.sourceview.editable_start_pos); // initialize epos..",
+               "        ",
+               "        var gotit= false;",
+               "        var line = spos.get_line();",
+               "        var endline = buf.get_line_count();",
+               "        while (line < endline) {",
+               "    \t\tline++;",
+               "\t        buf.get_iter_at_line(out epos, line);",
+               "\t        if (buf.get_source_marks_at_line(line, \"grey\").length() > 0) {",
+               "\t\t        buf.get_iter_at_line(out epos, line);\t    \t\t",
+               "\t    \t\tgotit=true;",
+               "\t    \t\tbreak;",
+               "    \t\t}",
+               "\t\t}",
+               "        ",
+               " \t\tif (gotit) {",
+               "\t \t\tprint(\"End Offset = %d/%d\\n\", epos.get_line(), epos.get_offset());",
+               "\t\t\t// get the pos...",
+               "\t\t\t// in theory the last char will be '}' or '},' .. or ','",
+               "\t\t\t// we should chop the ',' of the end...",
+               "\t\t\tvar str = buf.get_text(spos, epos, false);",
+               "\t\t\tprint(\"got string\\n%s\\n\", str);",
+               "\t\t",
+               "\t\t}",
+               "\t}",
+               "    return ;",
+               "}",
+               "",
+               " ",
+               ""
+              ]
+             },
+             "xtype" : "SourceBuffer",
+             "| bool checkSyntax" : [
+              " () {",
+              " ",
+              "   ",
+              "    var str = this.toString();",
+              "    ",
+              "    // needed???",
+              "    if (this.error_line > 0) {",
+              "         Gtk.TextIter start;",
+              "         Gtk.TextIter end;     ",
+              "        this.el.get_bounds (out start, out end);",
+              "",
+              "        this.el.remove_source_marks (start, end, \"WARN\");",
+              "        this.el.remove_source_marks (start, end, \"ERR\");        ",
+              "",
+              "    }",
+              "    ",
+              "    if (str.length < 1) {",
+              "        print(\"checkSyntax - empty string?\\n\");",
+              "        return false;",
+              "    }",
+              "    ",
+              "   if (_this.file == null) {",
+              "       return false;",
+              "   }",
+              "    var p = _this.file.project.palete;",
+              "    ",
+              " ",
+              "    if (_this.file.language != \"js\") {",
+              "\t\treturn false; // fake syntax error.",
+              "\t}",
+              "\t",
+              "    //Gee.HashMap<int,string> ret_x;",
+              "",
+              "\treturn p.javascriptHasErrors(",
+              "\t\t_this.main_window.windowstate,",
+              "        str, ",
+              "        null, // prop - not relivant.",
+              "        _this.file, ",
+              "        null",
+              "    );    ",
+              "     ",
+              "}",
+              ""
+             ],
+             "| 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" : [
+              "  () {",
+              "    ",
+              "    Gtk.TextIter s;",
+              "    Gtk.TextIter e;",
+              "    this.el.get_start_iter(out s);",
+              "    this.el.get_end_iter(out e);",
+              "    var ret = this.el.get_text(s,e,true);",
+              "    //print(\"TO STRING? \" + ret);",
+              "    return ret;",
+              "}",
+              " "
+             ]
+            }
+           ],
            "listeners" : {
-            "changed" : [
-             " () => {",
-             " ",
-             "",
-             "    // check syntax??",
-             "    // ??needed..??",
-             "   // _this.save_button.el.sensitive = true;",
-             "    ///?? has changed occured during loading?",
-             "    ",
-             "    // only trigger this if ",
-             "    ",
-             "    ",
-             "    ",
-             "    ",
-             "    if (_this.sourceview.loading) {",
-             "\t\treturn;",
-             "\t}",
+            "button_press_event" : [
+             "() => {",
              "\t",
-             "",
              "\t",
-             "    print(\"- PREVIEW EDITOR CHANGED--\");",
-             "",
-             "    this.dirty = true;  ",
-             "    this.checkSyntax(); // this calls backs and highlights errors.. in theory...  ",
-             "",
-             "",
+             "\tthis.button_is_pressed = true;",
+             "\treturn false;",
+             "}\t ",
+             ""
+            ],
+            "button_release_event" : [
+             "() => {",
              "",
-             "\tif (!_this.sourceview.button_is_pressed && !_this.sourceview.key_is_pressed) {",
-             "\t\tprint(\"button or key not pressed to generate change?!\\n\");",
-             "\t\treturn;",
-             "\t}",
-             "\t\t",
-             "    ",
-             "\t// what are we editing??",
-             "\tif (null == _this.sourceview.node_selected || _this.sourceview.prop_selected.length  < 1) {",
-             "\t\treturn;",
+             "\tprint(\"BUTTON RELEASE EVENT\\n\");",
+             "\tthis.onCursorChanged();",
+             "\tthis.button_is_pressed = false;",
+             "\treturn false;",
+             "}"
+            ],
+            "key_press_event" : [
+             "(src, key) => {",
+             "\tthis.key_is_pressed = true;",
+             "\t// is it ctrl-G -- find next?",
+             "\t// which will will still ignore..",
+             "\t ",
+             "\tif \t(key.str == \"g\" && key.state == Gdk.ModifierType.CONTROL_MASK) {",
+             "\t\tthis.key_is_pressed = false;",
              "\t}",
              "\t",
-             "\t// find the colon on the first line...",
+             "\t// if cursor postion is 'at start' of editing range, ",
+             "\t// and backspace is pressed...",
+             "\t// block it..",
              "\t",
-             "\tif (_this.sourceview.editable_start_pos > -1) {",
-             "\t\t",
-             "\t\tvar buf = (Gtk.SourceBuffer)_this.sourceview.el.get_buffer();",
-             "\t\t",
-             "        //print(\"cursor changed : %d\\n\", buf.cursor_position);",
-             "        Gtk.TextIter spos,epos;",
-             "        buf.get_iter_at_offset(out spos, _this.sourceview.editable_start_pos);",
-             "        buf.get_iter_at_offset(out epos, _this.sourceview.editable_start_pos); // initialize epos..",
-             "        ",
-             "        var gotit= false;",
-             "        var line = spos.get_line();",
-             "        var endline = buf.get_line_count();",
-             "        while (line < endline) {",
-             "    \t\tline++;",
-             "\t        buf.get_iter_at_line(out epos, line);",
-             "\t        if (buf.get_source_marks_at_line(line, \"grey\").length() > 0) {",
-             "\t\t        buf.get_iter_at_line(out epos, line);\t    \t\t",
-             "\t    \t\tgotit=true;",
-             "\t    \t\tbreak;",
-             "    \t\t}",
-             "\t\t}",
-             "        ",
-             " \t\tif (gotit) {",
-             "\t \t\tprint(\"End Offset = %d/%d\\n\", epos.get_line(), epos.get_offset());",
-             "\t\t\t// get the pos...",
-             "\t\t\t// in theory the last char will be '}' or '},' .. or ','",
-             "\t\t\t// we should chop the ',' of the end...",
-             "\t\t\tvar str = buf.get_text(spos, epos, false);",
-             "\t\t\tprint(\"got string\\n%s\\n\", str);",
-             "\t\t",
-             "\t\t}",
+             "\t var buf = this.el.get_buffer();",
+             "    //print(\"cursor changed : %d\\n\", buf.cursor_position);",
+             "       ",
+             "\tif (buf.cursor_position <= this.editable_start_pos && key.keyval == Gdk.Key.BackSpace) {",
+             "\t\treturn true; // block...",
              "\t}",
-             "    return ;",
+             "\t// what about 'last line of 'grey...'",
+             "\t// get the buffer - find the line, find the next line ?? see if it's grey?",
+             "\t",
+             "\t",
+             "\tprint(\"KEY PRESS EVENT \\n\");",
+             "\tthis.onCursorChanged();",
+             "\treturn false; ",
+             "}"
+            ],
+            "key_release_event" : [
+             "() => { ",
+             "\tthis.key_is_pressed = false;",
+             "\treturn false;",
              "}",
-             "",
-             " ",
              ""
             ]
            },
-           "xtype" : "SourceBuffer",
-           "| bool checkSyntax" : [
-            " () {",
+           "xtype" : "SourceView",
+           "| string toString" : [
+            "() {",
+            "   Gtk.TextIter s;",
+            "    Gtk.TextIter e;",
+            "    this.el.get_buffer().get_start_iter(out s);",
+            "    this.el.get_buffer().get_end_iter(out e);",
+            "    var ret = this.el.get_buffer().get_text(s,e,true);",
+            "    //print(\"TO STRING? \" + ret);",
+            "    return ret;",
+            "}",
+            ""
+           ],
+           "| void clearGreySelection" : [
+            "() {",
+            " // clear all the marks..",
+            "    var sbuf = (Gtk.SourceBuffer)this.el.buffer;",
+            "    ",
+            "    Gtk.TextIter start;",
+            "    Gtk.TextIter end;     ",
+            "        ",
+            "    sbuf.get_bounds (out start, out end);",
+            "    sbuf.remove_source_marks (start, end, \"grey\");",
+            "    ",
+            "    ",
+            "}",
+            ""
+           ],
+           "| 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;",
+            "    ",
+            "    ",
+            "    // get the cursor and scroll position....",
+            "    var buf = this.el.get_buffer();",
+            "\tvar cpos = buf.cursor_position;",
+            "    ",
+            "   print(\"BEFORE LOAD cursor = %d\\n\", cpos);",
+            "   ",
+            "    var vadj_pos = this.el.get_vadjustment().get_value();",
             "   ",
-            "    var str = this.toString();",
             "    ",
-            "    // needed???",
-            "    if (this.error_line > 0) {",
-            "         Gtk.TextIter start;",
-            "         Gtk.TextIter end;     ",
-            "        this.el.get_bounds (out start, out end);",
+            " ",
+            "    buf.set_text(\"\",0);",
+            "    var sbuf = (Gtk.SourceBuffer) buf;",
             "",
-            "        this.el.remove_source_marks (start, end, \"WARN\");",
-            "        this.el.remove_source_marks (start, end, \"ERR\");        ",
+            "    ",
             "",
+            "    if (_this.file == null || _this.file.xtype != \"Roo\") {",
+            "        print(\"xtype != Roo\");",
+            "        this.loading = false;",
+            "        return;",
             "    }",
             "    ",
-            "    if (str.length < 1) {",
-            "        print(\"checkSyntax - empty string?\\n\");",
-            "        return false;",
-            "    }",
+            "    // get the string from the rendered tree...",
+            "     ",
+            "     var str = _this.file.toSource();",
+            "     ",
+            "//    print(\"setting str %d\\n\", str.length);",
+            "    buf.set_text(str, str.length);",
+            "    var lm = Gtk.SourceLanguageManager.get_default();",
+            "     ",
+            "    //?? is javascript going to work as js?",
             "    ",
-            "   if (_this.file == null) {",
-            "       return false;",
-            "   }",
-            "    var p = _this.file.project.palete;",
+            "    ((Gtk.SourceBuffer)(buf)) .set_language(lm.get_language(_this.file.language));",
+            "  ",
             "    ",
-            " ",
-            "    if (_this.file.language != \"js\") {",
-            "\t\treturn false; // fake syntax error.",
-            "\t}",
-            "\t",
-            "    //Gee.HashMap<int,string> ret_x;",
+            "    Gtk.TextIter start;",
+            "    Gtk.TextIter end;     ",
+            "        ",
+            "    sbuf.get_bounds (out start, out end);",
+            "    sbuf.remove_source_marks (start, end, null); // remove all marks..",
+            "    ",
+            "     GLib.Timeout.add(500, () => {",
             "",
-            "\treturn p.javascriptHasErrors(",
-            "\t\t_this.main_window.windowstate,",
-            "        str, ",
-            "        null, // prop - not relivant.",
-            "        _this.file, ",
-            "        null",
-            "    );    ",
-            "     ",
+            "        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",
+            "\t\t",
+            "\t\t_this.buffer.checkSyntax();",
+            "\t\treturn false;",
+            "\t});",
+            "\t\t",
+            "    this.loading = false; ",
+            "    _this.buffer.dirty = false;",
             "}",
             ""
            ],
-           "| bool highlightErrors" : [
-            "( Gee.HashMap<int,string> validate_res) {",
-            "         ",
-            "    this.error_line = validate_res.size;",
+           "| void nodeSelected" : [
+            "(JsRender.Node? sel, bool scroll ) {",
+            "  ",
+            "    ",
             "\t",
-            "    if (this.error_line < 1) {",
-            "          return true;",
+            "    // this is connected in widnowstate",
+            "",
+            "",
+            "\t// not sure why....   ",
+            "    while(Gtk.events_pending()) {",
+            "        Gtk.main_iteration();",
             "    }",
-            "    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" : [
-            "  () {",
+            "    this.node_selected = sel;",
+            "    ",
+            "    this.updateGreySelection(scroll);",
+            "    ",
+            "    ",
             "    ",
-            "    Gtk.TextIter s;",
-            "    Gtk.TextIter e;",
-            "    this.el.get_start_iter(out s);",
-            "    this.el.get_end_iter(out e);",
-            "    var ret = this.el.get_text(s,e,true);",
-            "    //print(\"TO STRING? \" + ret);",
-            "    return ret;",
+            "}",
+            "",
+            "   ",
+            ""
+           ],
+           "| 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;",
+            "        }",
+            "        var prop = node.lineToProp(ln+1);",
+            "        print(\"prop : %s\", prop == null ? \"???\" : prop);",
+            "        ",
+            "        ",
+            "        // ---------- this selects the tree's node...",
+            "        ",
+            "        var ltree = _this.main_window.windowstate.left_tree;",
+            "        var tp = ltree.model.treePathFromNode(node);",
+            "        print(\"got tree path %s\\n\", tp);",
+            "        if (tp != \"\") {",
+            "\t         ",
+            "\t       ",
+            "\t        //print(\"changing cursor on tree..\\n\");",
+            "\t       ",
+            " ",
+            "            ",
+            "            // 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\t//var k = prop.get_key(kv[1]);",
+            "\t        \t\t// fixme -- need to determine if it's an editable property...",
+            "\t        \t\tthis.prop_selected = prop;",
+            "\t        \t\t",
+            "        \t\t} else if (kv[0] == \"l\") {",
+            "        \t\t\t this.prop_selected = prop;",
+            "        \t\t\t",
+            "        \t\t}",
+            "            }",
+            "            ltree.view.setCursor(tp, \"editor\");",
+            "           // 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) { ",
+            "\tvar sel = this.node_selected;",
+            "\tprint(\"node selected\\n\");",
+            "    var buf = this.el.get_buffer();",
+            "    var sbuf = (Gtk.SourceBuffer) buf;",
+            "",
+            "   ",
+            "   this.clearGreySelection();",
+            "   ",
+            "   ",
+            "   ",
+            "     if (sel == null) {",
+            "\t     print(\"no selected node\\n\");",
+            "        // no highlighting..",
+            "        return;",
+            "    }",
+            "    ",
+            "    print(\"highlight region %d to %d\\n\", sel.line_start,sel.line_end);",
+            "    Gtk.TextIter iter;   ",
+            "    sbuf.get_iter_at_line(out iter,  sel.line_start);",
+            "    ",
+            "    ",
+            "    Gtk.TextIter cur_iter;",
+            "    sbuf.get_iter_at_offset(out cur_iter, sbuf.cursor_position);",
+            "   ",
+            "    var cursor_at_line = cur_iter.get_line();",
+            "    ",
+            "    ",
+            "    //var cur_line = cur_iter.get_line();",
+            "    //if (cur_line > sel.line_start && cur_line < sel.line_end) {",
+            "    ",
+            "    //} else {",
+            "    if (scroll) {",
+            "\t\tprint(\"scrolling to node -- should occur on node picking.\\n\");",
+            "    \tthis.el.scroll_to_iter(iter,  0.1f, true, 0.0f, 0.5f);",
+            "\t}",
+            "    ",
+            "    var start_line = sel.line_start;",
+            "    var end_line = sel.line_end;",
+            "    ",
+            "    ",
+            "    this.el.editable = false;",
+            "    ",
+            "    //var colon_pos = 0;",
+            "    ",
+            "    this.editable_start_pos = -1;",
+            "    ",
+            "    // now if we have selected a property...",
+            "    if (this.prop_selected.length> 0 ) {",
+            "",
+            "\t\tint nstart, nend;",
+            "\t\tif (sel.getPropertyRange(this.prop_selected, out nstart, out nend) && nend > nstart) {",
+            "\t\t\tstart_line = nstart;",
+            "\t\t\tend_line = nend;",
+            "\t\t\tthis.el.editable = true;",
+            "\t\t\tprint(\"start line = %d, end line = %d\\n\", start_line, end_line);",
+            "\t\t\t",
+            "\t\t\t\t// see if we are 'right of ':'",
+            "\t\t\t\t// get an iter for the start of the line.",
+            "\t\t\tGtk.TextIter start_first_line_iter,end_first_line_iter;",
+            "\t\t\tthis.el.buffer.get_iter_at_line(out start_first_line_iter, start_line -1);",
+            "\t\t\tthis.el.buffer.get_iter_at_line(out end_first_line_iter, start_line -1);",
+            "\t\t\t ",
+            "\t\t\t",
+            "\t\t\t",
+            "\t\t\t",
+            "\t\t\tif (end_first_line_iter.forward_to_line_end()) {",
+            "\t\t\t\tvar first_line  = this.el.buffer.get_text(start_first_line_iter, end_first_line_iter, false);",
+            "\t\t\t\t",
+            "\t\t\t\tprint(\"first line = %s\\n\", first_line);",
+            "\t\t\t\tif (first_line.contains(\":\")) {",
+            "\t\t\t\t\tthis.editable_start_pos = start_first_line_iter.get_offset() + first_line.index_of(\":\") + 1;",
+            "\t\t\t\t\tprint(\"colon_pos  = %d\\n\", this.editable_start_pos);",
+            "\t\t\t\t}",
+            "\t\t\t\t",
+            "",
+            "\t\t\t\t//Gtk.TextIter colon_iter;",
+            "\t\t\t\t//sbuf.get_iter_at_offset (out colon_iter, colon_pos);",
+            "\t\t\t\t//sbuf.create_source_mark(null, \"active_text\", colon_iter);",
+            "\t\t\t}",
+            "\t\t\t",
+            "\t\t\t",
+            "\t\t\t",
+            "\t\t\t//print(\"is cursor at line? %d ?= %d\\n\", start_line -1 , cursor_at_line);",
+            "\t\t\t//if (start_line - 1 == cursor_at_line) {",
+            "\t\t\t// should be ok - current_posssion can not be less than '-1'...",
+            "\t\t\tif (sbuf.cursor_position < this.editable_start_pos) {",
+            "\t\t\t",
+            "\t\t\t\tprint(\"cursor is before start pos.. - turn off editable...\\n\");",
+            "\t\t\t\t//var before_cursor_string = this.el.buffer.get_text(start_line_iter, cur_iter, false);",
+            "\t\t\t\t//print(\"before cursor string =  %s\\n\", before_cursor_string);",
+            "\t\t\t\t//if (!before_cursor_string.contains(\":\")) {",
+            "\t\t\t\t\tthis.el.editable = false;",
+            "\t\t\t\t//}",
+            "\t\t\t\t",
+            "\t\t\t}",
+            "\t\t\t ",
+            "\t\t\t ",
+            "",
+            "\t\t\t ",
+            "\t\t}",
+            "\t\tprint(\"propSelected = %s range  %d -> %d\\n\", this.prop_selected, start_line, end_line);\t\t",
+            "\t\t",
+            "\t\t",
+            "    }",
+            "    ",
+            "\tprint(\"checking selection\\n\");",
+            "    ",
+            "    ",
+            "    // check selection - if it's out of 'bounds'",
+            "    if (this.el.editable && sbuf.get_has_selection()) {",
+            "\t\tGtk.TextIter sel_start_iter, sel_end_iter;",
+            "\t\tsbuf.get_selection_bounds(out sel_start_iter, out sel_end_iter);",
+            "\t\t",
+            "\t\tif (sel_start_iter.get_line() < start_line || sel_end_iter.get_line() > end_line ||",
+            "\t\t\tsel_start_iter.get_line() > end_line   || sel_end_iter.get_line() < start_line\t\t\t) {",
+            "\t\t\t// save?",
+            "\t\t\tthis.el.editable = false;",
+            "\t\t}",
+            "\t\tif (this.editable_start_pos > 0 &&",
+            "\t\t\t(sel_start_iter.get_offset() < this.editable_start_pos || sel_end_iter.get_offset() < this.editable_start_pos)",
+            "\t\t\t",
+            "\t\t) {",
+            "\t\t\tthis.el.editable = false;",
+            "\t\t}",
+            "\t\t",
+            "\t\t ",
+            "    ",
+            "    }",
+            "    ",
+            "    ",
+            "    ",
+            "    ",
+            "    for (var i = 0; i < buf.get_line_count();i++) {",
+            "        if (i < (start_line -1) || i > (end_line -1)) {",
+            "           ",
+            "            sbuf.get_iter_at_line(out iter, i);",
+            "            sbuf.create_source_mark(null, \"grey\", iter);",
+            "            ",
+            "        }",
+            "    ",
+            "    }",
+            "    if (scroll && (cursor_at_line > end_line || cursor_at_line < start_line)) {",
+            "\t    Gtk.TextIter cpos_iter;",
+            "\t\tbuf.get_iter_at_line(out cpos_iter, start_line);",
+            "\t\t",
+            "\t\tbuf.place_cursor(cpos_iter); ",
+            "\t}",
+            "",
+            "",
+            "}"
            ]
           }
          ],
-         "listeners" : {
-          "button_press_event" : [
-           "() => {",
-           "\t",
-           "\t",
-           "\tthis.button_is_pressed = true;",
-           "\treturn false;",
-           "}\t ",
-           ""
-          ],
-          "button_release_event" : [
-           "() => {",
-           "",
-           "\tprint(\"BUTTON RELEASE EVENT\\n\");",
-           "\tthis.onCursorChanged();",
-           "\tthis.button_is_pressed = false;",
-           "\treturn false;",
-           "}"
-          ],
-          "key_press_event" : [
-           "(src, key) => {",
-           "\tthis.key_is_pressed = true;",
-           "\t// is it ctrl-G -- find next?",
-           "\t// which will will still ignore..",
-           "\t ",
-           "\tif \t(key.str == \"g\" && key.state == Gdk.ModifierType.CONTROL_MASK) {",
-           "\t\tthis.key_is_pressed = false;",
-           "\t}",
-           "\t",
-           "\t// if cursor postion is 'at start' of editing range, ",
-           "\t// and backspace is pressed...",
-           "\t// block it..",
-           "\t",
-           "\t var buf = this.el.get_buffer();",
-           "    //print(\"cursor changed : %d\\n\", buf.cursor_position);",
-           "       ",
-           "\tif (buf.cursor_position <= this.editable_start_pos && key.keyval == Gdk.Key.BackSpace) {",
-           "\t\treturn true; // block...",
-           "\t}",
-           "\t// what about 'last line of 'grey...'",
-           "\t// get the buffer - find the line, find the next line ?? see if it's grey?",
-           "\t",
-           "\t",
-           "\tprint(\"KEY PRESS EVENT \\n\");",
-           "\tthis.onCursorChanged();",
-           "\treturn false; ",
-           "}"
-          ],
-          "key_release_event" : [
-           "() => { ",
-           "\tthis.key_is_pressed = false;",
-           "\treturn false;",
-           "}",
-           ""
-          ]
-         },
-         "xtype" : "SourceView",
-         "| string toString" : [
-          "() {",
-          "   Gtk.TextIter s;",
-          "    Gtk.TextIter e;",
-          "    this.el.get_buffer().get_start_iter(out s);",
-          "    this.el.get_buffer().get_end_iter(out e);",
-          "    var ret = this.el.get_buffer().get_text(s,e,true);",
-          "    //print(\"TO STRING? \" + ret);",
-          "    return ret;",
-          "}",
-          ""
-         ],
-         "| void clearGreySelection" : [
-          "() {",
-          " // clear all the marks..",
-          "    var sbuf = (Gtk.SourceBuffer)this.el.buffer;",
-          "    ",
-          "    Gtk.TextIter start;",
-          "    Gtk.TextIter end;     ",
-          "        ",
-          "    sbuf.get_bounds (out start, out end);",
-          "    sbuf.remove_source_marks (start, end, \"grey\");",
-          "    ",
-          "    ",
-          "}",
-          ""
-         ],
-         "| 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;",
-          "    ",
-          "    ",
-          "    // get the cursor and scroll position....",
-          "    var buf = this.el.get_buffer();",
-          "\tvar cpos = buf.cursor_position;",
-          "    ",
-          "   print(\"BEFORE LOAD cursor = %d\\n\", cpos);",
-          "   ",
-          "    var vadj_pos = this.el.get_vadjustment().get_value();",
-          "   ",
-          "    ",
-          " ",
-          "    buf.set_text(\"\",0);",
-          "    var sbuf = (Gtk.SourceBuffer) buf;",
-          "",
-          "    ",
-          "",
-          "    if (_this.file == null || _this.file.xtype != \"Roo\") {",
-          "        print(\"xtype != Roo\");",
-          "        this.loading = false;",
-          "        return;",
-          "    }",
-          "    ",
-          "    // get the string from the rendered tree...",
-          "     ",
-          "     var str = _this.file.toSource();",
-          "     ",
-          "//    print(\"setting str %d\\n\", str.length);",
-          "    buf.set_text(str, str.length);",
-          "    var lm = Gtk.SourceLanguageManager.get_default();",
-          "     ",
-          "    //?? is javascript going to work as js?",
-          "    ",
-          "    ((Gtk.SourceBuffer)(buf)) .set_language(lm.get_language(_this.file.language));",
-          "  ",
-          "    ",
-          "    Gtk.TextIter start;",
-          "    Gtk.TextIter end;     ",
-          "        ",
-          "    sbuf.get_bounds (out start, out end);",
-          "    sbuf.remove_source_marks (start, end, null); // remove all marks..",
-          "    ",
-          "     GLib.Timeout.add(500, () => {",
-          "",
-          "        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",
-          "\t\t",
-          "\t\t_this.buffer.checkSyntax();",
-          "\t\treturn false;",
-          "\t});",
-          "\t\t",
-          "    this.loading = false; ",
-          "    _this.buffer.dirty = false;",
-          "}",
-          ""
-         ],
-         "| void nodeSelected" : [
-          "(JsRender.Node? sel, bool scroll ) {",
-          "  ",
-          "    ",
-          "\t",
-          "    // this is connected in widnowstate",
-          "",
-          "",
-          "\t// not sure why....   ",
-          "    while(Gtk.events_pending()) {",
-          "        Gtk.main_iteration();",
-          "    }",
-          "    ",
-          "    this.node_selected = sel;",
-          "    ",
-          "    this.updateGreySelection(scroll);",
-          "    ",
-          "    ",
-          "    ",
-          "}",
-          "",
-          "   ",
-          ""
-         ],
-         "| 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;",
-          "        }",
-          "        var prop = node.lineToProp(ln+1);",
-          "        print(\"prop : %s\", prop == null ? \"???\" : prop);",
-          "        ",
-          "        ",
-          "        // ---------- this selects the tree's node...",
-          "        ",
-          "        var ltree = _this.main_window.windowstate.left_tree;",
-          "        var tp = ltree.model.treePathFromNode(node);",
-          "        print(\"got tree path %s\\n\", tp);",
-          "        if (tp != \"\") {",
-          "\t         ",
-          "\t       ",
-          "\t        //print(\"changing cursor on tree..\\n\");",
-          "\t       ",
-          " ",
-          "            ",
-          "            // 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\t//var k = prop.get_key(kv[1]);",
-          "\t        \t\t// fixme -- need to determine if it's an editable property...",
-          "\t        \t\tthis.prop_selected = prop;",
-          "\t        \t\t",
-          "        \t\t} else if (kv[0] == \"l\") {",
-          "        \t\t\t this.prop_selected = prop;",
-          "        \t\t\t",
-          "        \t\t}",
-          "            }",
-          "            ltree.view.setCursor(tp, \"editor\");",
-          "           // 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) { ",
-          "\tvar sel = this.node_selected;",
-          "\tprint(\"node selected\\n\");",
-          "    var buf = this.el.get_buffer();",
-          "    var sbuf = (Gtk.SourceBuffer) buf;",
-          "",
-          "   ",
-          "   this.clearGreySelection();",
-          "   ",
-          "   ",
-          "   ",
-          "     if (sel == null) {",
-          "\t     print(\"no selected node\\n\");",
-          "        // no highlighting..",
-          "        return;",
-          "    }",
-          "    ",
-          "    print(\"highlight region %d to %d\\n\", sel.line_start,sel.line_end);",
-          "    Gtk.TextIter iter;   ",
-          "    sbuf.get_iter_at_line(out iter,  sel.line_start);",
-          "    ",
-          "    ",
-          "    Gtk.TextIter cur_iter;",
-          "    sbuf.get_iter_at_offset(out cur_iter, sbuf.cursor_position);",
-          "   ",
-          "    var cursor_at_line = cur_iter.get_line();",
-          "    ",
-          "    ",
-          "    //var cur_line = cur_iter.get_line();",
-          "    //if (cur_line > sel.line_start && cur_line < sel.line_end) {",
-          "    ",
-          "    //} else {",
-          "    if (scroll) {",
-          "\t\tprint(\"scrolling to node -- should occur on node picking.\\n\");",
-          "    \tthis.el.scroll_to_iter(iter,  0.1f, true, 0.0f, 0.5f);",
-          "\t}",
-          "    ",
-          "    var start_line = sel.line_start;",
-          "    var end_line = sel.line_end;",
-          "    ",
-          "    ",
-          "    this.el.editable = false;",
-          "    ",
-          "    //var colon_pos = 0;",
-          "    ",
-          "    this.editable_start_pos = -1;",
-          "    ",
-          "    // now if we have selected a property...",
-          "    if (this.prop_selected.length> 0 ) {",
-          "",
-          "\t\tint nstart, nend;",
-          "\t\tif (sel.getPropertyRange(this.prop_selected, out nstart, out nend) && nend > nstart) {",
-          "\t\t\tstart_line = nstart;",
-          "\t\t\tend_line = nend;",
-          "\t\t\tthis.el.editable = true;",
-          "\t\t\tprint(\"start line = %d, end line = %d\\n\", start_line, end_line);",
-          "\t\t\t",
-          "\t\t\t\t// see if we are 'right of ':'",
-          "\t\t\t\t// get an iter for the start of the line.",
-          "\t\t\tGtk.TextIter start_first_line_iter,end_first_line_iter;",
-          "\t\t\tthis.el.buffer.get_iter_at_line(out start_first_line_iter, start_line -1);",
-          "\t\t\tthis.el.buffer.get_iter_at_line(out end_first_line_iter, start_line -1);",
-          "\t\t\t ",
-          "\t\t\t",
-          "\t\t\t",
-          "\t\t\t",
-          "\t\t\tif (end_first_line_iter.forward_to_line_end()) {",
-          "\t\t\t\tvar first_line  = this.el.buffer.get_text(start_first_line_iter, end_first_line_iter, false);",
-          "\t\t\t\t",
-          "\t\t\t\tprint(\"first line = %s\\n\", first_line);",
-          "\t\t\t\tif (first_line.contains(\":\")) {",
-          "\t\t\t\t\tthis.editable_start_pos = start_first_line_iter.get_offset() + first_line.index_of(\":\") + 1;",
-          "\t\t\t\t\tprint(\"colon_pos  = %d\\n\", this.editable_start_pos);",
-          "\t\t\t\t}",
-          "\t\t\t\t",
-          "",
-          "\t\t\t\t//Gtk.TextIter colon_iter;",
-          "\t\t\t\t//sbuf.get_iter_at_offset (out colon_iter, colon_pos);",
-          "\t\t\t\t//sbuf.create_source_mark(null, \"active_text\", colon_iter);",
-          "\t\t\t}",
-          "\t\t\t",
-          "\t\t\t",
-          "\t\t\t",
-          "\t\t\t//print(\"is cursor at line? %d ?= %d\\n\", start_line -1 , cursor_at_line);",
-          "\t\t\t//if (start_line - 1 == cursor_at_line) {",
-          "\t\t\t// should be ok - current_posssion can not be less than '-1'...",
-          "\t\t\tif (sbuf.cursor_position < this.editable_start_pos) {",
-          "\t\t\t",
-          "\t\t\t\tprint(\"cursor is before start pos.. - turn off editable...\\n\");",
-          "\t\t\t\t//var before_cursor_string = this.el.buffer.get_text(start_line_iter, cur_iter, false);",
-          "\t\t\t\t//print(\"before cursor string =  %s\\n\", before_cursor_string);",
-          "\t\t\t\t//if (!before_cursor_string.contains(\":\")) {",
-          "\t\t\t\t\tthis.el.editable = false;",
-          "\t\t\t\t//}",
-          "\t\t\t\t",
-          "\t\t\t}",
-          "\t\t\t ",
-          "\t\t\t ",
-          "",
-          "\t\t\t ",
-          "\t\t}",
-          "\t\tprint(\"propSelected = %s range  %d -> %d\\n\", this.prop_selected, start_line, end_line);\t\t",
-          "\t\t",
-          "\t\t",
-          "    }",
-          "    ",
-          "\tprint(\"checking selection\\n\");",
-          "    ",
-          "    ",
-          "    // check selection - if it's out of 'bounds'",
-          "    if (this.el.editable && sbuf.get_has_selection()) {",
-          "\t\tGtk.TextIter sel_start_iter, sel_end_iter;",
-          "\t\tsbuf.get_selection_bounds(out sel_start_iter, out sel_end_iter);",
-          "\t\t",
-          "\t\tif (sel_start_iter.get_line() < start_line || sel_end_iter.get_line() > end_line ||",
-          "\t\t\tsel_start_iter.get_line() > end_line   || sel_end_iter.get_line() < start_line\t\t\t) {",
-          "\t\t\t// save?",
-          "\t\t\tthis.el.editable = false;",
-          "\t\t}",
-          "\t\tif (this.editable_start_pos > 0 &&",
-          "\t\t\t(sel_start_iter.get_offset() < this.editable_start_pos || sel_end_iter.get_offset() < this.editable_start_pos)",
-          "\t\t\t",
-          "\t\t) {",
-          "\t\t\tthis.el.editable = false;",
-          "\t\t}",
-          "\t\t",
-          "\t\t ",
-          "    ",
-          "    }",
-          "    ",
-          "    ",
-          "    ",
-          "    ",
-          "    for (var i = 0; i < buf.get_line_count();i++) {",
-          "        if (i < (start_line -1) || i > (end_line -1)) {",
-          "           ",
-          "            sbuf.get_iter_at_line(out iter, i);",
-          "            sbuf.create_source_mark(null, \"grey\", iter);",
-          "            ",
-          "        }",
-          "    ",
-          "    }",
-          "    if (scroll && (cursor_at_line > end_line || cursor_at_line < start_line)) {",
-          "\t    Gtk.TextIter cpos_iter;",
-          "\t\tbuf.get_iter_at_line(out cpos_iter, start_line);",
-          "\t\t",
-          "\t\tbuf.place_cursor(cpos_iter); ",
-          "\t}",
-          "",
-          "",
-          "}"
-         ]
-        }
-       ],
-       "xtype" : "ScrolledWindow"
-      }
-     ],
-     "xtype" : "Notebook"
-    },
-    {
-     "$ xns" : "Gtk",
-     "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
-     "bool homogeneous" : false,
-     "bool vexpand" : false,
-     "int spacing" : 0,
-     "items" : [
-      {
-       "$ xns" : "Gtk",
-       "* init" : [
-        "var description =   Pango.FontDescription.from_string(\"monospace\");",
-        "\tdescription.set_size(8000);",
-        "\t this.el.override_font(description);",
-        "",
-        ""
-       ],
-       "bool hexpand" : true,
-       "id" : "search_entry",
-       "int width_request" : 300,
-       "listeners" : {
-        "changed" : [
-         "() => {",
-         "\t/*",
-         "\tif (this.el.text == \"\") {",
-         "\t\t_this.search_results.el.hide();",
-         "\t\treturn;",
-         "\t}",
-         "\tvar res = 0;",
-         "\tswitch(_this.windowstate.state) {",
-         "\t\tcase WindowState.State.CODEONLY:",
-         "\t\t///case WindowState.State.CODE:",
-         "\t\t\t// search the code being edited..",
-         "\t\t\tres = _this.windowstate.code_editor_tab.search(this.el.text);",
-         "\t\t\t",
-         "\t\t\tbreak;",
-         "\t\tcase WindowState.State.PREVIEW:",
-         "\t\t\tif (_this.windowstate.file.xtype == \"Gtk\") {",
-         "\t\t\t\t res = _this.windowstate.window_gladeview.search(this.el.text);",
-         "\t\t\t} else { ",
-         "\t\t\t\t res = _this.windowstate.window_rooview.search(this.el.text);\t\t\t",
-         "\t\t\t}",
-         "\t\t",
-         "\t\t",
-         "\t\t\tbreak;",
-         "\t}",
-         "\t_this.search_results.el.show();",
-         "\tif (res > 0) {",
-         "\t\t_this.search_results.el.label = \"%d Matches\".printf(res);",
-         "\t} else {",
-         "\t\t_this.search_results.el.label = \"No Matches\";",
-         "\t}",
-         "\t\t",
-         "\t*/",
-         "\t",
-         "}",
-         ""
-        ],
-        "key_press_event" : [
-         "(event) => {",
-         "    ",
-         "  ",
-         " \tif (event.keyval == Gdk.Key.Return && this.el.text.length > 0) {",
-         "\t\tvar res = _this.search(this.el.text);",
-         "\t\tif (res > 0) {",
-         "\t\t\t_this.search_results.el.label = \"%d Matches\".printf(res);",
-         "\t\t} else {",
-         "\t\t\t_this.search_results.el.label = \"No Matches\";",
-         "\t\t}",
-         "\t\t",
-         "\t    return true;",
-         "",
-         "\t}    ",
-         "   // print(event.key.keyval)",
-         "   ",
-         "    return false;",
-         "",
-         "} "
-        ]
-       },
-       "string placeholder_text" : "Press enter to search",
-       "xtype" : "SearchEntry",
-       "| void forwardSearch" : [
-        "(bool change_focus) {",
-        "",
-        "",
-        "\t_this.forwardSearch(change_focus);",
-        "",
-        "/*",
-        "",
-        "\tswitch(_this.windowstate.state) {",
-        "\t\tcase WindowState.State.CODEONLY:",
-        "\t\t//case WindowState.State.CODE:",
-        "\t\t\t// search the code being edited..",
-        "\t\t\t_this.windowstate.code_editor_tab.forwardSearch(change_focus);",
-        "\t\t\t ",
-        "\t\t\tbreak;",
-        "\t\tcase WindowState.State.PREVIEW:",
-        "\t\t\tif (_this.windowstate.file.xtype == \"Gtk\") {",
-        "\t\t\t\t_this.windowstate.window_gladeview.forwardSearch(change_focus);",
-        "\t\t\t} else { ",
-        "\t\t\t\t _this.windowstate.window_rooview.forwardSearch(change_focus);",
-        "\t\t\t}",
-        "\t\t",
-        "\t\t\tbreak;",
-        "\t}",
-        "\t*/",
-        "\t",
-        "}",
-        ""
-       ]
-      },
-      {
-       "$ xns" : "Gtk",
-       "* pack" : "add",
-       "items" : [
-        {
-         "$ xns" : "Gtk",
-         "* pack" : "add",
-         "Xcls_ValaCompileErrors popup" : "",
-         "bool always_show_image" : true,
-         "id" : "search_results",
-         "items" : [
-          {
-           "$ xns" : "Gtk",
-           "* pack" : "set_image",
-           "bool sensitive" : false,
-           "utf8 icon_name" : "system-search",
-           "xtype" : "Image"
-          }
-         ],
-         "listeners" : {
-          "button_press_event" : [
-           "() => {",
-           "/*",
-           "    if (this.popup == null) {",
-           "        this.popup = new Xcls_ValaCompileErrors();",
-           "        this.popup.window = _this;",
-           "    }",
-           "   ",
-           "    ",
-           "    this.popup.show(this.notices, this.el);",
-           "    */",
-           "    return true;",
-           "}"
-          ]
-         },
-         "string label" : "Matches",
-         "xtype" : "ImageMenuItem"
-        }
-       ],
-       "xtype" : "MenuBar"
-      },
-      {
-       "$ xns" : "Gtk",
-       "bool always_show_image" : true,
-       "items" : [
-        {
-         "$ xns" : "Gtk",
-         "* prop" : "image",
-         "string icon_name" : "go-down",
-         "xtype" : "Image"
-        }
-       ],
-       "listeners" : {
-        "button_press_event" : [
-         "(event) => {",
-         "",
-         "\t_this.forwardSearch(true);",
-         "\t",
-         "\treturn true;",
-         "}",
-         ""
-        ]
-       },
-       "string label" : "Next",
-       "xtype" : "Button"
-      },
-      {
-       "$ xns" : "Gtk",
-       "bool always_show_image" : true,
-       "items" : [
-        {
-         "$ xns" : "Gtk",
-         "* prop" : "image",
-         "string icon_name" : "go-up",
-         "xtype" : "Image"
-        }
-       ],
-       "listeners" : {
-        "button_press_event" : [
-         "(event) => {",
-         "",
-         "\t_this.backSearch(true);",
-         "\t",
-         "\treturn true;",
-         "}",
-         ""
-        ]
-       },
-       "string label" : "Previous",
-       "xtype" : "Button"
-      },
-      {
-       "$ xns" : "Gtk",
-       "bool always_show_image" : true,
-       "items" : [
-        {
-         "$ xns" : "Gtk",
-         "* prop" : "image",
-         "string icon_name" : "emblem-system",
-         "xtype" : "Image"
+         "xtype" : "ScrolledWindow"
         },
         {
          "$ xns" : "Gtk",
-         "* prop" : "popup",
-         "id" : "search_settings",
+         "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
+         "bool homogeneous" : false,
+         "bool vexpand" : false,
+         "int spacing" : 0,
          "items" : [
           {
            "$ xns" : "Gtk",
            "* init" : [
-            "{",
-            "\tthis.el.show();",
+            "var description =   Pango.FontDescription.from_string(\"monospace\");",
+            "\tdescription.set_size(8000);",
+            "\t this.el.override_font(description);",
+            "",
+            ""
+           ],
+           "bool hexpand" : true,
+           "id" : "search_entry",
+           "int width_request" : 300,
+           "listeners" : {
+            "changed" : [
+             "() => {",
+             "\t/*",
+             "\tif (this.el.text == \"\") {",
+             "\t\t_this.search_results.el.hide();",
+             "\t\treturn;",
+             "\t}",
+             "\tvar res = 0;",
+             "\tswitch(_this.windowstate.state) {",
+             "\t\tcase WindowState.State.CODEONLY:",
+             "\t\t///case WindowState.State.CODE:",
+             "\t\t\t// search the code being edited..",
+             "\t\t\tres = _this.windowstate.code_editor_tab.search(this.el.text);",
+             "\t\t\t",
+             "\t\t\tbreak;",
+             "\t\tcase WindowState.State.PREVIEW:",
+             "\t\t\tif (_this.windowstate.file.xtype == \"Gtk\") {",
+             "\t\t\t\t res = _this.windowstate.window_gladeview.search(this.el.text);",
+             "\t\t\t} else { ",
+             "\t\t\t\t res = _this.windowstate.window_rooview.search(this.el.text);\t\t\t",
+             "\t\t\t}",
+             "\t\t",
+             "\t\t",
+             "\t\t\tbreak;",
+             "\t}",
+             "\t_this.search_results.el.show();",
+             "\tif (res > 0) {",
+             "\t\t_this.search_results.el.label = \"%d Matches\".printf(res);",
+             "\t} else {",
+             "\t\t_this.search_results.el.label = \"No Matches\";",
+             "\t}",
+             "\t\t",
+             "\t*/",
+             "\t",
+             "}",
+             ""
+            ],
+            "key_press_event" : [
+             "(event) => {",
+             "    ",
+             "  ",
+             " \tif (event.keyval == Gdk.Key.Return && this.el.text.length > 0) {",
+             "\t\tvar res = _this.search(this.el.text);",
+             "\t\tif (res > 0) {",
+             "\t\t\t_this.search_results.el.label = \"%d Matches\".printf(res);",
+             "\t\t} else {",
+             "\t\t\t_this.search_results.el.label = \"No Matches\";",
+             "\t\t}",
+             "\t\t",
+             "\t    return true;",
+             "",
+             "\t}    ",
+             "   // print(event.key.keyval)",
+             "   ",
+             "    return false;",
+             "",
+             "} "
+            ]
+           },
+           "string placeholder_text" : "Press enter to search",
+           "xtype" : "SearchEntry",
+           "| void forwardSearch" : [
+            "(bool change_focus) {",
+            "",
+            "",
+            "\t_this.forwardSearch(change_focus);",
+            "",
+            "/*",
+            "",
+            "\tswitch(_this.windowstate.state) {",
+            "\t\tcase WindowState.State.CODEONLY:",
+            "\t\t//case WindowState.State.CODE:",
+            "\t\t\t// search the code being edited..",
+            "\t\t\t_this.windowstate.code_editor_tab.forwardSearch(change_focus);",
+            "\t\t\t ",
+            "\t\t\tbreak;",
+            "\t\tcase WindowState.State.PREVIEW:",
+            "\t\t\tif (_this.windowstate.file.xtype == \"Gtk\") {",
+            "\t\t\t\t_this.windowstate.window_gladeview.forwardSearch(change_focus);",
+            "\t\t\t} else { ",
+            "\t\t\t\t _this.windowstate.window_rooview.forwardSearch(change_focus);",
+            "\t\t\t}",
+            "\t\t",
+            "\t\t\tbreak;",
+            "\t}",
+            "\t*/",
+            "\t",
             "}",
             ""
+           ]
+          },
+          {
+           "$ xns" : "Gtk",
+           "* pack" : "add",
+           "items" : [
+            {
+             "$ xns" : "Gtk",
+             "* pack" : "add",
+             "Xcls_ValaCompileErrors popup" : "",
+             "bool always_show_image" : true,
+             "id" : "search_results",
+             "items" : [
+              {
+               "$ xns" : "Gtk",
+               "* pack" : "set_image",
+               "bool sensitive" : false,
+               "utf8 icon_name" : "system-search",
+               "xtype" : "Image"
+              }
+             ],
+             "listeners" : {
+              "button_press_event" : [
+               "() => {",
+               "/*",
+               "    if (this.popup == null) {",
+               "        this.popup = new Xcls_ValaCompileErrors();",
+               "        this.popup.window = _this;",
+               "    }",
+               "   ",
+               "    ",
+               "    this.popup.show(this.notices, this.el);",
+               "    */",
+               "    return true;",
+               "}"
+              ]
+             },
+             "string label" : "Matches",
+             "xtype" : "ImageMenuItem"
+            }
            ],
-           "id" : "case_sensitive",
-           "string label" : "Case Sensitive",
-           "xtype" : "CheckMenuItem"
+           "xtype" : "MenuBar"
           },
           {
            "$ xns" : "Gtk",
-           "* init" : [
-            "{",
-            "\tthis.el.show();",
-            "}",
-            ""
+           "bool always_show_image" : true,
+           "items" : [
+            {
+             "$ xns" : "Gtk",
+             "* prop" : "image",
+             "string icon_name" : "go-down",
+             "xtype" : "Image"
+            }
            ],
-           "id" : "regex",
-           "string label" : "Regex",
-           "xtype" : "CheckMenuItem"
+           "listeners" : {
+            "button_press_event" : [
+             "(event) => {",
+             "",
+             "\t_this.forwardSearch(true);",
+             "\t",
+             "\treturn true;",
+             "}",
+             ""
+            ]
+           },
+           "string label" : "Next",
+           "xtype" : "Button"
           },
           {
            "$ xns" : "Gtk",
-           "* init" : [
-            "{",
-            "\tthis.el.show();",
-            "}",
-            ""
+           "bool always_show_image" : true,
+           "items" : [
+            {
+             "$ xns" : "Gtk",
+             "* prop" : "image",
+             "string icon_name" : "go-up",
+             "xtype" : "Image"
+            }
            ],
-           "id" : "multiline",
-           "string label" : "Multi-line (add \\n)",
-           "xtype" : "CheckMenuItem"
+           "listeners" : {
+            "button_press_event" : [
+             "(event) => {",
+             "",
+             "\t_this.backSearch(true);",
+             "\t",
+             "\treturn true;",
+             "}",
+             ""
+            ]
+           },
+           "string label" : "Previous",
+           "xtype" : "Button"
+          },
+          {
+           "$ xns" : "Gtk",
+           "bool always_show_image" : true,
+           "items" : [
+            {
+             "$ xns" : "Gtk",
+             "* prop" : "image",
+             "string icon_name" : "emblem-system",
+             "xtype" : "Image"
+            },
+            {
+             "$ xns" : "Gtk",
+             "* prop" : "popup",
+             "id" : "search_settings",
+             "items" : [
+              {
+               "$ xns" : "Gtk",
+               "* init" : [
+                "{",
+                "\tthis.el.show();",
+                "}",
+                ""
+               ],
+               "id" : "case_sensitive",
+               "string label" : "Case Sensitive",
+               "xtype" : "CheckMenuItem"
+              },
+              {
+               "$ xns" : "Gtk",
+               "* init" : [
+                "{",
+                "\tthis.el.show();",
+                "}",
+                ""
+               ],
+               "id" : "regex",
+               "string label" : "Regex",
+               "xtype" : "CheckMenuItem"
+              },
+              {
+               "$ xns" : "Gtk",
+               "* init" : [
+                "{",
+                "\tthis.el.show();",
+                "}",
+                ""
+               ],
+               "id" : "multiline",
+               "string label" : "Multi-line (add \\n)",
+               "xtype" : "CheckMenuItem"
+              }
+             ],
+             "xtype" : "Menu"
+            }
+           ],
+           "string label" : "Settings",
+           "xtype" : "MenuButton"
           }
          ],
-         "xtype" : "Menu"
+         "xtype" : "Box"
         }
        ],
-       "string label" : "Settings",
-       "xtype" : "MenuButton"
+       "xtype" : "Box"
       }
      ],
-     "xtype" : "Box"
+     "xtype" : "Notebook"
     }
    ],
    "xtype" : "Box",
index 933c927..2b9a974 100644 (file)
@@ -54,9 +54,6 @@ public class Xcls_WindowRooView : Object
         var child_0 = new Xcls_notebook( _this );
         child_0.ref();
         this.el.pack_start (  child_0.el , true,true,0 );
-        var child_1 = new Xcls_Box18( _this );
-        child_1.ref();
-        this.el.add(  child_1.el );
     }
 
     // user defined functions
@@ -256,9 +253,6 @@ public class Xcls_WindowRooView : Object
             var child_3 = new Xcls_Box14( _this );
             child_3.ref();
             this.el.append_page (  child_3.el , _this.label_code.el );
-            var child_4 = new Xcls_ScrolledWindow15( _this );
-            child_4.ref();
-            this.el.append_page (  child_4.el , _this.label_code.el );
         }
 
         // user defined functions
@@ -989,16 +983,21 @@ public class Xcls_WindowRooView : Object
         public Xcls_Box14(Xcls_WindowRooView _owner )
         {
             _this = _owner;
-            this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
+            this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
 
             // my vars (dec)
 
             // set gobject values
+            var child_0 = new Xcls_ScrolledWindow15( _this );
+            child_0.ref();
+            this.el.add(  child_0.el );
+            var child_1 = new Xcls_Box18( _this );
+            child_1.ref();
+            this.el.add(  child_1.el );
         }
 
         // user defined functions
     }
-
     public class Xcls_ScrolledWindow15 : Object
     {
         public Gtk.ScrolledWindow el;
@@ -1016,6 +1015,7 @@ public class Xcls_WindowRooView : Object
             // my vars (dec)
 
             // set gobject values
+            this.el.vexpand = true;
             var child_0 = new Xcls_sourceview( _this );
             child_0.ref();
             this.el.add (  child_0.el  );
@@ -1692,7 +1692,6 @@ public class Xcls_WindowRooView : Object
 
 
 
-
     public class Xcls_Box18 : Object
     {
         public Gtk.Box el;
@@ -2228,4 +2227,6 @@ public class Xcls_WindowRooView : Object
 
 
 
+
+
 }