Fix #7238 - remove clutter and change layout of interface
[roobuilder] / src / Builder4 / WindowRooView.bjs
1 {
2  "build_module" : "builder",
3  "items" : [
4   {
5    "# Gtk.Widget lastObj" : "null",
6    "# JsRender.JsRender file" : "null",
7    "# Xcls_MainWindow main_window" : "",
8    "$ xns" : "Gtk",
9    "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
10    "Gtk.SourceSearchContext searchcontext" : "",
11    "bool hexpand" : true,
12    "bool vexpand" : true,
13    "id" : "WindowRooView",
14    "int last_search_end" : 0,
15    "items" : [
16     {
17      "$ xns" : "Gtk",
18      "* pack" : "pack_start,true,true,0",
19      "id" : "notebook",
20      "items" : [
21       {
22        "$ xns" : "Gtk",
23        "* pack" : false,
24        "id" : "label_preview",
25        "utf8 label" : "Preview",
26        "xtype" : "Label"
27       },
28       {
29        "$ xns" : "Gtk",
30        "* pack" : false,
31        "id" : "label_code",
32        "utf8 label" : "Preview Generated Code",
33        "xtype" : "Label"
34       },
35       {
36        "$ xns" : "Gtk",
37        "* pack" : "append_page,_this.label_preview.el",
38        "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
39        "id" : "paned",
40        "items" : [
41         {
42          "$ homogeneous" : false,
43          "$ xns" : "Gtk",
44          "* pack" : "pack1,true,true",
45          "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
46          "id" : "viewbox",
47          "items" : [
48           {
49            "$ height_request" : 20,
50            "$ homogeneous" : true,
51            "$ vexpand" : false,
52            "$ xns" : "Gtk",
53            "* pack" : "pack_start,false,true,0",
54            "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
55            "items" : [
56             {
57              "$ xns" : "Gtk",
58              "* pack" : "pack_start,false,false,0",
59              "label" : "Redraw",
60              "listeners" : {
61               "clicked" : [
62                "( ) => {",
63                "    _this.view.renderJS(  true);",
64                "}"
65               ]
66              },
67              "xtype" : "Button"
68             },
69             {
70              "$ active" : true,
71              "$ xns" : "Gtk",
72              "* pack" : "pack_start,false,false,0",
73              "id" : "AutoRedraw",
74              "label" : "Auto Redraw On",
75              "listeners" : {
76               "toggled" : [
77                " (state) => {",
78                "    this.el.set_label(this.el.active  ? \"Auto Redraw On\" : \"Auto Redraw Off\");",
79                "}"
80               ]
81              },
82              "xtype" : "CheckButton"
83             },
84             {
85              "$ xns" : "Gtk",
86              "* pack" : "pack_start,false,false,0",
87              "label" : "Full Redraw",
88              "listeners" : {
89               "clicked" : [
90                " () => {",
91                "  _this.view.redraws = 99;",
92                "    _this.view.el.web_context.clear_cache();  ",
93                "  //_this.view.renderJS(true);",
94                "  FakeServerCache.clear();",
95                "  _this.view.reInit();",
96                "",
97                "}"
98               ]
99              },
100              "xtype" : "Button"
101             }
102            ],
103            "xtype" : "Box"
104           },
105           {
106            "$ shadow_type" : "Gtk.ShadowType.IN",
107            "$ xns" : "Gtk",
108            "* init" : [
109             "  this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);",
110             " ",
111             ""
112            ],
113            "* pack" : "pack_end,true,true,0",
114            "id" : "viewcontainer",
115            "items" : [
116             {
117              "# GLib.DateTime lastRedraw" : "null",
118              "# WebKit.WebInspector inspector" : "",
119              "# bool pendingRedraw" : false,
120              "# bool refreshRequired" : false,
121              "# int redraws" : 0,
122              "# string renderedData" : "\"\"",
123              "# string runhtml" : "\"\"",
124              "# string runjs" : "\"\"",
125              "$ xns" : "WebKit",
126              "* init" : [
127               " {",
128               "    // this may not work!?",
129               "    var settings =  this.el.get_settings();",
130               "    settings.enable_developer_extras = true;",
131               "    ",
132               "    ",
133               "    var fs= new FakeServer(this.el);",
134               "    fs.ref();",
135               "    // this was an attempt to change the url perms.. did not work..",
136               "    // settings.enable_file_access_from_file_uris = true;",
137               "    // settings.enable_offline_web_application_cache - true;",
138               "    // settings.enable_universal_access_from_file_uris = true;",
139               "   ",
140               "     ",
141               "    ",
142               "    ",
143               "    ",
144               "",
145               "     // FIXME - base url of script..",
146               "     // we need it so some of the database features work.",
147               "    this.el.load_html( \"Render not ready\" , ",
148               "            //fixme - should be a config option!",
149               "            // or should we catch stuff and fix it up..",
150               "            \"http://localhost/app.Builder/\"",
151               "    );",
152               "        ",
153               "        ",
154               "   //this.el.open('file:///' + __script_path__ + '/../builder.html');",
155               "    /*",
156               "    Gtk.drag_dest_set",
157               "    (",
158               "            this.el,              //",
159               "            Gtk.DestDefaults.MOTION  | Gtk.DestDefaults.HIGHLIGHT,",
160               "            null,            // list of targets",
161               "            Gdk.DragAction.COPY         // what to do with data after dropped ",
162               "    );",
163               "                            ",
164               "   // print(\"RB: TARGETS : \" + LeftTree.atoms[\"STRING\"]);",
165               "    Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList);",
166               "    */",
167               "    GLib.Timeout.add_seconds(1,  ()  =>{",
168               "         //print(\"run refresh?\");",
169               "         if (this.el == null) {",
170               "            return false;",
171               "         }",
172               "         this.runRefresh(); ",
173               "         return true;",
174               "     });",
175               "    ",
176               "    ",
177               "}",
178               ""
179              ],
180              "* pack" : "add",
181              "id" : "view",
182              "listeners" : {
183               "drag_drop" : [
184                "  ( ctx, x, y,time, ud) => {",
185                "    return false;",
186                "    /*",
187                "\tprint(\"TARGET: drag-drop\");",
188                "        var is_valid_drop_site = true;",
189                "        ",
190                "         ",
191                "        Gtk.drag_get_data",
192                "        (",
193                "                w,         // will receive 'drag-data-received' signal ",
194                "                ctx,        /* represents the current state of the DnD ",
195                "                this.get('/Window').atoms[\"STRING\"],    /* the target type we want ",
196                "                time            /* time stamp ",
197                "        );",
198                "                        ",
199                "                        ",
200                "                        /* No target offered by source => error ",
201                "                       ",
202                "",
203                "\treturn  is_valid_drop_site;",
204                "\t*/",
205                "}"
206               ],
207               "load_changed" : [
208                "(le) => {",
209                "    if (le != WebKit.LoadEvent.FINISHED) {",
210                "        return;",
211                "    }",
212                "    if (this.runjs.length < 1) {",
213                "        return;",
214                "    }",
215                "  //  this.el.run_javascript(this.runjs, null);",
216                "     FakeServerCache.remove(    this.runjs);",
217                "    this.runjs = \"\";",
218                "}"
219               ],
220               "script_dialog" : [
221                " (dialog) => {",
222                "    ",
223                "    ",
224                "    if (this.el == null) {",
225                "        return true;",
226                "    }",
227                "    ",
228                "     var msg = dialog.get_message();",
229                "     if (msg.length < 4) {",
230                "        return false;",
231                "     }",
232                "     if (msg.substring(0,4) != \"IPC:\") {",
233                "         return false;",
234                "     }",
235                "     var ar = msg.split(\":\", 3);",
236                "    if (ar.length < 3) {",
237                "        return false;",
238                "    }",
239                "",
240                "    switch(ar[1]) {",
241                "        case \"SAVEHTML\":",
242                "\t        print(\"GOT saveHTML %d?\\n\", ar[2].length);",
243                "            _this.file.saveHTML(ar[2]);",
244                "            return true;",
245                "        default:",
246                "            return false;",
247                "    }",
248                "    ",
249                "}"
250               ],
251               "show" : [
252                "  ( ) => {",
253                "    this.initInspector();;",
254                "}"
255               ]
256              },
257              "redraws" : 0,
258              "xtype" : "WebView",
259              "| void initInspector" : [
260               "() {",
261               "    ",
262               "   /* if (this.inspector == this.el.get_inspector()) {",
263               "        this.inspector.show();",
264               "        this.inspector.open_window();        ",
265               "        print(\"init inspecter called, and inspector is the same as existing\\n\");",
266               "        return;",
267               "    }",
268               "    print(\"new inspector?\\n\");",
269               "*/",
270               "    this.inspector = this.el.get_inspector();",
271               "    this.inspector.ref();",
272               "    ",
273               "    // got a new inspector...",
274               "        ",
275               "    this.inspector.open_window.connect(() => {",
276               "         this.inspector = this.el.get_inspector();",
277               "        print(\"inspector attach\\n\");",
278               "        var wv = this.inspector.get_web_view();",
279               "        if (wv != null) {",
280               "            print(\"got inspector web view\\n\");",
281               "            ",
282               "            var cn = _this.inspectorcontainer.el.get_child();",
283               "            if (cn != null) {",
284               "                 _this.inspectorcontainer.el.remove(cn);",
285               "             }",
286               "            ",
287               "            _this.inspectorcontainer.el.add(wv);",
288               "            wv.show();",
289               "        } else {",
290               "            //this.inspector.close();",
291               "            ",
292               "            //this.inspector = null;",
293               "           ",
294               " ",
295               "        }",
296               "        return true;",
297               "       ",
298               "    });",
299               "    /*",
300               "    this.inspector.closed.connect(() => {",
301               "         print(\"inspector closed?!?\");",
302               "         // if this happens destroy the webkit..",
303               "         // recreate it..",
304               "         this.el.stop_loading();",
305               "         ",
306               "         if (_this.viewbox.el.get_parent() == null) {",
307               "            return;",
308               "         }",
309               "         ",
310               "         ",
311               "        _this.viewbox.el.remove(_this.viewcontainer.el);",
312               "        _this.el.remove(_this.inspectorcontainer.el);        ",
313               "         ",
314               "         // destory seems to cause problems.",
315               "         //this.el.destroy();",
316               "        //_this.viewcontainer.el.destroy();",
317               "         //_this.inspectorcontainer.el.destroy();",
318               "",
319               "         this.el = null;         ",
320               "         var nv =new Xcls_viewcontainer(_this);",
321               "         nv.ref();",
322               "         _this.viewbox.el.pack_end(nv.el,true,true,0);",
323               "         ",
324               "          var  inv =new Xcls_inspectorcontainer(_this);",
325               "          inv.ref();",
326               "          _this.el.pack2(inv.el,true,true);",
327               "         ",
328               "         inv.el.show_all();",
329               "         nv.el.show_all();",
330               "         //while(Gtk.events_pending ()) Gtk.main_iteration ();",
331               "         //_this.view.renderJS(true); ",
332               "         _this.view.refreshRequired  = true;",
333               "       ",
334               "    }); ",
335               "    */",
336               "    ",
337               "    this.inspector.show();",
338               "}",
339               ""
340              ],
341              "| void reInit" : [
342               "() {",
343               "   print(\"reInit?\");",
344               "         // if this happens destroy the webkit..",
345               "         // recreate it..",
346               "     this.el.stop_loading();",
347               "         ",
348               "     if (_this.viewbox.el.get_parent() == null) {",
349               "        return;",
350               "     }",
351               "         ",
352               "         ",
353               "    _this.viewbox.el.remove(_this.viewcontainer.el);",
354               "    _this.paned.el.remove(_this.inspectorcontainer.el);        ",
355               "         ",
356               "         // destory seems to cause problems.",
357               "         //this.el.destroy();",
358               "        //_this.viewcontainer.el.destroy();",
359               "         //_this.inspectorcontainer.el.destroy();",
360               "     var  inv =new Xcls_inspectorcontainer(_this);",
361               "      inv.ref();",
362               "      _this.paned.el.pack2(inv.el,true,true);",
363               "      ",
364               "      ",
365               "     this.el = null;         ",
366               "     var nv =new Xcls_viewcontainer(_this);",
367               "     nv.ref();",
368               "     _this.viewbox.el.pack_end(nv.el,true,true,0);",
369               "         ",
370               "         ",
371               "     inv.el.show_all();",
372               "     nv.el.show_all();",
373               "         //while(Gtk.events_pending ()) Gtk.main_iteration ();",
374               "         //_this.view.renderJS(true); ",
375               "     _this.view.refreshRequired  = true;",
376               "}",
377               ""
378              ],
379              "| void renderJS" : [
380               "(bool force) {",
381               "",
382               "    // this is the public redraw call..",
383               "    // we refresh in a loop privately..",
384               "    var autodraw = _this.AutoRedraw.el.active;",
385               "    if (!autodraw && !force) {",
386               "        print(\"Skipping redraw - no force, and autodraw off\");",
387               "        return;",
388               "    }",
389               "     ",
390               "    this.refreshRequired  = true;",
391               "}",
392               ""
393              ],
394              "| void runRefresh" : [
395               " () ",
396               "{",
397               "    // this is run every 2 seconds from the init..",
398               "",
399               "  ",
400               "    ",
401               "    if (!this.refreshRequired) {",
402               "       // print(\"no refresh required\");",
403               "        return;",
404               "    }",
405               "",
406               "    if (this.lastRedraw != null) {",
407               "       // do not redraw if last redraw was less that 5 seconds ago.",
408               "       if ((int64)(new DateTime.now_local()).difference(this.lastRedraw) < 5000 ) {",
409               "            return;",
410               "        }",
411               "    }",
412               "    ",
413               "    if (_this.file == null) {",
414               "        return;",
415               "    }",
416               "    ",
417               "    ",
418               "     this.refreshRequired = false;",
419               "   //  print(\"HTML RENDERING\");",
420               "     ",
421               "     ",
422               "     //this.get('/BottomPane').el.show();",
423               "     //this.get('/BottomPane').el.set_current_page(2);// webkit inspector",
424               "    _this.file.webkit_page_id  = this.el.get_page_id();",
425               "    ",
426               "    var js = _this.file.toSourcePreview();",
427               "",
428               "    if (js.length < 1) {",
429               "        print(\"no data\");",
430               "        return;",
431               "    }",
432               "//    var  data = js[0];",
433               "    this.redraws++;",
434               "  ",
435               "    var project = _this.file.project;  ",
436               "",
437               "     //print (project.fn);",
438               "     // set it to non-empty.",
439               "     ",
440               "//     runhtml = runhtml.length ?  runhtml : '<script type=\"text/javascript\"></script>'; ",
441               "",
442               "",
443               "//   this.runhtml  = this.runhtml || '';",
444               " ",
445               " ",
446               "    // then we need to reload the browser using",
447               "    // load_html_string..",
448               "",
449               "    // then trigger a redraw once it's loaded..",
450               "    this.pendingRedraw = true;",
451               "",
452               "    var runhtml = \"<script type=\\\"text/javascript\\\">\\n\" ;",
453               "    string builderhtml;",
454               "    ",
455               "    try {",
456               "        GLib.FileUtils.get_contents(BuilderApplication.configDirectory() + \"/resources/roo.builder.js\", out builderhtml);",
457               "    } catch (Error e) {",
458               "        builderhtml = \"\";",
459               "    }",
460               "",
461               "    runhtml += builderhtml + \"\\n\";",
462               "    runhtml += \"</script>\\n\" ;",
463               "",
464               "    // fix to make sure they are the same..",
465               "    this.runhtml = project.runhtml;",
466               "    // need to modify paths",
467               "",
468               "    string inhtml;",
469               "    var base_template = _this.file.project.base_template;",
470               "    ",
471               "    if (base_template.length > 0 && !FileUtils.test(",
472               "        BuilderApplication.configDirectory() + \"/resources/\" +  base_template, FileTest.EXISTS)  ",
473               "        ) {",
474               "           print(\"invalid base_template name - using default:  %s\\n\", base_template);",
475               "           base_template = \"\";",
476               "    ",
477               "    }",
478               "    try {",
479               "        GLib.FileUtils.get_contents(",
480               "            BuilderApplication.configDirectory() + \"/resources/\" + ",
481               "                (base_template.length > 0 ? base_template :  \"roo.builder.html\")",
482               "                , out inhtml);",
483               "    ",
484               "    } catch (Error e) {",
485               "        inhtml = \"\";",
486               "    }    ",
487               "    this.renderedData = js;",
488               "",
489               "",
490               "    string js_src = js + \"\\n\" +",
491               "\t\"Roo.onReady(function() {\\n\" +",
492               "\t\"if (\" + _this.file.name +\".show) \" +  _this.file.name +\".show({});\\n\" +",
493               "\t\"Roo.XComponent.build();\\n\" +",
494               "\t\"});\\n\";",
495               "\t",
496               "   // print(\"render js: \" + js);",
497               "    //if (!this.ready) {",
498               "  //      console.log('not loaded yet');",
499               "    //}",
500               "    this.lastRedraw = new DateTime.now_local();",
501               "",
502               "",
503               "    //this.runjs = js_src;",
504               "    var fc =    FakeServerCache.factory_with_data(js_src);",
505               "    this.runjs = fc.fname;",
506               "    ",
507               "        var html = inhtml.replace(\"</head>\", runhtml + this.runhtml + ",
508               "            \"<script type=\\\"text/javascript\\\" src=\\\"xhttp://localhost\" + fc.fname + \"\\\"></script>\" +   ",
509               "              //  \"<script type=\\\"text/javascript\\\">\\n\" +",
510               "              //  js_src + \"\\n\" + ",
511               "              //  \"</script>\" + ",
512               "                        ",
513               "        \"</head>\");",
514               "        //print(\"LOAD HTML \" + html);",
515               "        ",
516               "         var rootURL = _this.file.project.rootURL;",
517               "   ",
518               "        ",
519               "        ",
520               "        this.el.load_html( html , ",
521               "            //fixme - should be a config option!",
522               "            (rootURL.length > 0 ? rootURL : \"xhttp://localhost/roobuilder/\")",
523               "        );",
524               "        ",
525               "    // force the inspector...        ",
526               "       //   this.initInspector();",
527               "        ",
528               "        // - no need for this, the builder javascript will call it when build is complete",
529               "        //GLib.Timeout.add_seconds(1, () => {",
530               "        //    this.el.run_javascript(\"Builder.saveHTML()\",null);",
531               "        //    return false;",
532               "        //});",
533               "//     print( \"before render\" +    this.lastRedraw);",
534               "//    print( \"after render\" +    (new Date()));",
535               "    ",
536               "}",
537               "                                                                                                                                                                                                                        "
538              ]
539             }
540            ],
541            "xtype" : "ScrolledWindow"
542           }
543          ],
544          "xtype" : "Box"
545         },
546         {
547          "$ shadow_type" : "Gtk.ShadowType.IN",
548          "$ xns" : "Gtk",
549          "* init" : [
550           "  this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);",
551           " ",
552           ""
553          ],
554          "* pack" : "pack2,true,true",
555          "id" : "inspectorcontainer",
556          "xtype" : "ScrolledWindow"
557         }
558        ],
559        "xtype" : "Paned"
560       },
561       {
562        "$ xns" : "Gtk",
563        "* pack" : "append_page,_this.label_code.el",
564        "items" : [
565         {
566          "# JsRender.Node? node_selected" : "null",
567          "# bool button_is_pressed" : false,
568          "# bool key_is_pressed" : false,
569          "# bool loading" : true,
570          "# int editable_start_pos" : "-1",
571          "$ string prop_selected" : "\"\"",
572          "$ xns" : "Gtk",
573          "* init" : [
574           "{",
575           "   ",
576           "   ",
577           "    var description =   Pango.FontDescription.from_string(\"monospace\");",
578           "    description.set_size(8000);",
579           "    this.el.override_font(description);",
580           "",
581           "    this.loading = true;",
582           "    //var buf = this.el.get_buffer();",
583           "    //buf.notify.connect(this.onCursorChanged);",
584           "  ",
585           "  ",
586           "    var attrs = new Gtk.SourceMarkAttributes();",
587           "    var  pink =   Gdk.RGBA();",
588           "    pink.parse ( \"pink\");",
589           "    attrs.set_background ( pink);",
590           "    attrs.set_icon_name ( \"process-stop\");    ",
591           "    attrs.query_tooltip_text.connect(( mark) => {",
592           "        //print(\"tooltip query? %s\\n\", mark.name);",
593           "        return mark.name;",
594           "    });",
595           "    ",
596           "    this.el.set_mark_attributes (\"ERR\", attrs, 1);",
597           "    ",
598           "     var wattrs = new Gtk.SourceMarkAttributes();",
599           "    var  blue =   Gdk.RGBA();",
600           "    blue.parse ( \"#ABF4EB\");",
601           "    wattrs.set_background ( blue);",
602           "    wattrs.set_icon_name ( \"process-stop\");    ",
603           "    wattrs.query_tooltip_text.connect(( mark) => {",
604           "        //print(\"tooltip query? %s\\n\", mark.name);",
605           "        return mark.name;",
606           "    });",
607           "    ",
608           "    this.el.set_mark_attributes (\"WARN\", wattrs, 1);",
609           "    ",
610           " ",
611           "    ",
612           "     var dattrs = new Gtk.SourceMarkAttributes();",
613           "    var  purple =   Gdk.RGBA();",
614           "    purple.parse ( \"#EEA9FF\");",
615           "    dattrs.set_background ( purple);",
616           "    dattrs.set_icon_name ( \"process-stop\");    ",
617           "    dattrs.query_tooltip_text.connect(( mark) => {",
618           "        //print(\"tooltip query? %s\\n\", mark.name);",
619           "        return mark.name;",
620           "    });",
621           "    ",
622           "    this.el.set_mark_attributes (\"DEPR\", dattrs, 1);",
623           "    ",
624           "    ",
625           "    var gattrs = new Gtk.SourceMarkAttributes();",
626           "    var  grey =   Gdk.RGBA();",
627           "    grey.parse ( \"#ccc\");",
628           "    gattrs.set_background ( grey);",
629           " ",
630           "    ",
631           "    this.el.set_mark_attributes (\"grey\", gattrs, 1);",
632           "    ",
633           "    ",
634           "    ",
635           "    ",
636           "    ",
637           "    ",
638           "}",
639           " "
640          ],
641          "* pack" : "add",
642          "gboolean editable" : false,
643          "gboolean show_line_marks" : true,
644          "gboolean show_line_numbers" : true,
645          "id" : "sourceview",
646          "items" : [
647           {
648            "$ xns" : "Gtk",
649            "* pack" : "set_buffer",
650            "bool dirty" : false,
651            "id" : "buffer",
652            "int error_line" : "-1",
653            "listeners" : {
654             "changed" : [
655              " () => {",
656              " ",
657              "",
658              "    // check syntax??",
659              "    // ??needed..??",
660              "   // _this.save_button.el.sensitive = true;",
661              "    ///?? has changed occured during loading?",
662              "    ",
663              "    // only trigger this if ",
664              "    ",
665              "    ",
666              "    ",
667              "    ",
668              "    if (_this.sourceview.loading) {",
669              "\t\treturn;",
670              "\t}",
671              "\t",
672              "",
673              "\t",
674              "    print(\"- PREVIEW EDITOR CHANGED--\");",
675              "",
676              "    this.dirty = true;  ",
677              "    this.checkSyntax(); // this calls backs and highlights errors.. in theory...  ",
678              "",
679              "",
680              "",
681              "\tif (!_this.sourceview.button_is_pressed && !_this.sourceview.key_is_pressed) {",
682              "\t\tprint(\"button or key not pressed to generate change?!\\n\");",
683              "\t\treturn;",
684              "\t}",
685              "\t\t",
686              "    ",
687              "\t// what are we editing??",
688              "\tif (null == _this.sourceview.node_selected || _this.sourceview.prop_selected.length  < 1) {",
689              "\t\treturn;",
690              "\t}",
691              "\t",
692              "\t// find the colon on the first line...",
693              "\t",
694              "\tif (_this.sourceview.editable_start_pos > -1) {",
695              "\t\t",
696              "\t\tvar buf = (Gtk.SourceBuffer)_this.sourceview.el.get_buffer();",
697              "\t\t",
698              "        //print(\"cursor changed : %d\\n\", buf.cursor_position);",
699              "        Gtk.TextIter spos,epos;",
700              "        buf.get_iter_at_offset(out spos, _this.sourceview.editable_start_pos);",
701              "        buf.get_iter_at_offset(out epos, _this.sourceview.editable_start_pos); // initialize epos..",
702              "        ",
703              "        var gotit= false;",
704              "        var line = spos.get_line();",
705              "        var endline = buf.get_line_count();",
706              "        while (line < endline) {",
707              "    \t\tline++;",
708              "\t        buf.get_iter_at_line(out epos, line);",
709              "\t        if (buf.get_source_marks_at_line(line, \"grey\").length() > 0) {",
710              "\t\t        buf.get_iter_at_line(out epos, line);\t    \t\t",
711              "\t    \t\tgotit=true;",
712              "\t    \t\tbreak;",
713              "    \t\t}",
714              "\t\t}",
715              "        ",
716              " \t\tif (gotit) {",
717              "\t \t\tprint(\"End Offset = %d/%d\\n\", epos.get_line(), epos.get_offset());",
718              "\t\t\t// get the pos...",
719              "\t\t\t// in theory the last char will be '}' or '},' .. or ','",
720              "\t\t\t// we should chop the ',' of the end...",
721              "\t\t\tvar str = buf.get_text(spos, epos, false);",
722              "\t\t\tprint(\"got string\\n%s\\n\", str);",
723              "\t\t",
724              "\t\t}",
725              "\t}",
726              "    return ;",
727              "}",
728              "",
729              " ",
730              ""
731             ]
732            },
733            "xtype" : "SourceBuffer",
734            "|   bool checkSyntax" : [
735             " () {",
736             " ",
737             "   ",
738             "    var str = this.toString();",
739             "    ",
740             "    // needed???",
741             "    if (this.error_line > 0) {",
742             "         Gtk.TextIter start;",
743             "         Gtk.TextIter end;     ",
744             "        this.el.get_bounds (out start, out end);",
745             "",
746             "        this.el.remove_source_marks (start, end, \"WARN\");",
747             "        this.el.remove_source_marks (start, end, \"ERR\");        ",
748             "",
749             "    }",
750             "    ",
751             "    if (str.length < 1) {",
752             "        print(\"checkSyntax - empty string?\\n\");",
753             "        return false;",
754             "    }",
755             "    ",
756             "   if (_this.file == null) {",
757             "       return false;",
758             "   }",
759             "    var p = _this.file.project.palete;",
760             "    ",
761             " ",
762             "    if (_this.file.language != \"js\") {",
763             "\t\treturn false; // fake syntax error.",
764             "\t}",
765             "\t",
766             "    //Gee.HashMap<int,string> ret_x;",
767             "",
768             "\treturn p.javascriptHasErrors(",
769             "\t\t_this.main_window.windowstate,",
770             "        str, ",
771             "         \"\", // _this.key, ",
772             "        \"file\", //_this.ptype,",
773             "        _this.file, ",
774             "        null",
775             "    );    ",
776             "     ",
777             "}",
778             ""
779            ],
780            "|   string toString" : [
781             "  () {",
782             "    ",
783             "    Gtk.TextIter s;",
784             "    Gtk.TextIter e;",
785             "    this.el.get_start_iter(out s);",
786             "    this.el.get_end_iter(out e);",
787             "    var ret = this.el.get_text(s,e,true);",
788             "    //print(\"TO STRING? \" + ret);",
789             "    return ret;",
790             "}",
791             " "
792            ],
793            "| bool highlightErrors" : [
794             "( Gee.HashMap<int,string> validate_res) {",
795             "         ",
796             "    this.error_line = validate_res.size;",
797             "\t",
798             "    if (this.error_line < 1) {",
799             "          return true;",
800             "    }",
801             "    var tlines = this.el.get_line_count ();",
802             "    Gtk.TextIter iter;",
803             "    var valiter = validate_res.map_iterator();",
804             "    while (valiter.next()) {",
805             "    ",
806             "//        print(\"get inter\\n\");",
807             "        var eline = valiter.get_key();",
808             "        if (eline > tlines) {",
809             "            continue;",
810             "        }",
811             "        this.el.get_iter_at_line( out iter, eline);",
812             "        //print(\"mark line\\n\");",
813             "        this.el.create_source_mark(valiter.get_value(), \"ERR\", iter);",
814             "    }   ",
815             "    return false;",
816             "}"
817            ]
818           }
819          ],
820          "listeners" : {
821           "button_press_event" : [
822            "() => {",
823            "\t",
824            "\t",
825            "\tthis.button_is_pressed = true;",
826            "\treturn false;",
827            "}\t ",
828            ""
829           ],
830           "button_release_event" : [
831            "() => {",
832            "",
833            "\tprint(\"BUTTON RELEASE EVENT\\n\");",
834            "\tthis.onCursorChanged();",
835            "\tthis.button_is_pressed = false;",
836            "\treturn false;",
837            "}"
838           ],
839           "key_press_event" : [
840            "(src, key) => {",
841            "\tthis.key_is_pressed = true;",
842            "\t// is it ctrl-G -- find next?",
843            "\t// which will will still ignore..",
844            "\t ",
845            "\tif \t(key.str == \"g\" && key.state == Gdk.ModifierType.CONTROL_MASK) {",
846            "\t\tthis.key_is_pressed = false;",
847            "\t}",
848            "\t",
849            "\t// if cursor postion is 'at start' of editing range, ",
850            "\t// and backspace is pressed...",
851            "\t// block it..",
852            "\t",
853            "\t var buf = this.el.get_buffer();",
854            "    //print(\"cursor changed : %d\\n\", buf.cursor_position);",
855            "       ",
856            "\tif (buf.cursor_position <= this.editable_start_pos && key.keyval == Gdk.Key.BackSpace) {",
857            "\t\treturn true; // block...",
858            "\t}",
859            "\t// what about 'last line of 'grey...'",
860            "\t// get the buffer - find the line, find the next line ?? see if it's grey?",
861            "\t",
862            "\t",
863            "\tprint(\"KEY PRESS EVENT \\n\");",
864            "\tthis.onCursorChanged();",
865            "\treturn false; ",
866            "}"
867           ],
868           "key_release_event" : [
869            "() => { ",
870            "\tthis.key_is_pressed = false;",
871            "\treturn false;",
872            "}",
873            ""
874           ]
875          },
876          "xtype" : "SourceView",
877          "| string toString" : [
878           "() {",
879           "   Gtk.TextIter s;",
880           "    Gtk.TextIter e;",
881           "    this.el.get_buffer().get_start_iter(out s);",
882           "    this.el.get_buffer().get_end_iter(out e);",
883           "    var ret = this.el.get_buffer().get_text(s,e,true);",
884           "    //print(\"TO STRING? \" + ret);",
885           "    return ret;",
886           "}",
887           ""
888          ],
889          "| void clearGreySelection" : [
890           "() {",
891           " // clear all the marks..",
892           "    var sbuf = (Gtk.SourceBuffer)this.el.buffer;",
893           "    ",
894           "    Gtk.TextIter start;",
895           "    Gtk.TextIter end;     ",
896           "        ",
897           "    sbuf.get_bounds (out start, out end);",
898           "    sbuf.remove_source_marks (start, end, \"grey\");",
899           "    ",
900           "    ",
901           "}",
902           ""
903          ],
904          "| void highlightErrorsJson" : [
905           " (string type, Json.Object obj) {",
906           "       // this is a hook for the vala code - it has no value in javascript ",
907           "       // as we only have one error ususally....",
908           "        return  ;",
909           "    ",
910           " ",
911           "",
912           "",
913           "}"
914          ],
915          "| void loadFile" : [
916           "( ) {",
917           "    this.loading = true;",
918           "    ",
919           "    ",
920           "    // get the cursor and scroll position....",
921           "    var buf = this.el.get_buffer();",
922           "\tvar cpos = buf.cursor_position;",
923           "    ",
924           "   print(\"BEFORE LOAD cursor = %d\\n\", cpos);",
925           "   ",
926           "    var vadj_pos = this.el.get_vadjustment().get_value();",
927           "   ",
928           "    ",
929           " ",
930           "    buf.set_text(\"\",0);",
931           "    var sbuf = (Gtk.SourceBuffer) buf;",
932           "",
933           "    ",
934           "",
935           "    if (_this.file == null || _this.file.xtype != \"Roo\") {",
936           "        print(\"xtype != Roo\");",
937           "        this.loading = false;",
938           "        return;",
939           "    }",
940           "    ",
941           "    // get the string from the rendered tree...",
942           "     ",
943           "     var str = _this.file.toSource();",
944           "     ",
945           "//    print(\"setting str %d\\n\", str.length);",
946           "    buf.set_text(str, str.length);",
947           "    var lm = Gtk.SourceLanguageManager.get_default();",
948           "     ",
949           "    //?? is javascript going to work as js?",
950           "    ",
951           "    ((Gtk.SourceBuffer)(buf)) .set_language(lm.get_language(_this.file.language));",
952           "  ",
953           "    ",
954           "    Gtk.TextIter start;",
955           "    Gtk.TextIter end;     ",
956           "        ",
957           "    sbuf.get_bounds (out start, out end);",
958           "    sbuf.remove_source_marks (start, end, null); // remove all marks..",
959           "    ",
960           "     GLib.Timeout.add(500, () => {",
961           "",
962           "        print(\"RESORTING cursor to = %d\\n\", cpos);",
963           "\t\tGtk.TextIter cpos_iter;",
964           "\t\tbuf.get_iter_at_offset(out cpos_iter, cpos);",
965           "\t\tbuf.place_cursor(cpos_iter); ",
966           "\t\t",
967           "\t\tthis.el.get_vadjustment().set_value(vadj_pos);;",
968           "\t\t",
969           "",
970           "\t\tthis.onCursorChanged();",
971           "\t\t",
972           "\t\t",
973           "\t\t_this.buffer.checkSyntax();",
974           "\t\treturn false;",
975           "\t});",
976           "\t\t",
977           "    this.loading = false; ",
978           "    _this.buffer.dirty = false;",
979           "}",
980           ""
981          ],
982          "| void nodeSelected" : [
983           "(JsRender.Node? sel, bool scroll ) {",
984           "  ",
985           "    ",
986           "\t",
987           "    // this is connected in widnowstate",
988           "",
989           "",
990           "\t// not sure why....   ",
991           "    while(Gtk.events_pending()) {",
992           "        Gtk.main_iteration();",
993           "    }",
994           "    ",
995           "    this.node_selected = sel;",
996           "    ",
997           "    this.updateGreySelection(scroll);",
998           "    ",
999           "    ",
1000           "    ",
1001           "}",
1002           "",
1003           "   ",
1004           ""
1005          ],
1006          "| void onCursorChanged" : [
1007           "(/*ParamSpec ps*/) {",
1008           "",
1009           "\t\tif (!this.key_is_pressed && !this.button_is_pressed) {",
1010           "\t\t\treturn;",
1011           "\t\t}",
1012           "",
1013           "\t   if (this.loading) {",
1014           "            return;",
1015           "        }",
1016           "       // if (ps.name != \"cursor-position\") {",
1017           "       //     return;",
1018           "       // }",
1019           "",
1020           "        var buf = this.el.get_buffer();",
1021           "        //print(\"cursor changed : %d\\n\", buf.cursor_position);",
1022           "        Gtk.TextIter cpos;",
1023           "        buf.get_iter_at_offset(out cpos, buf.cursor_position);",
1024           "        ",
1025           "        var ln = cpos.get_line();",
1026           "        ",
1027           "        ",
1028           "        // --- select node at line....",
1029           "        ",
1030           "        var node = _this.file.lineToNode(ln+1);",
1031           " ",
1032           "        if (node == null) {",
1033           "            print(\"can not find node\\n\");",
1034           "            return;",
1035           "        }",
1036           "        var prop = node.lineToProp(ln+1);",
1037           "        print(\"prop : %s\", prop == null ? \"???\" : prop);",
1038           "        ",
1039           "        ",
1040           "        // ---------- this selects the tree's node...",
1041           "        ",
1042           "        var ltree = _this.main_window.windowstate.left_tree;",
1043           "        var tp = ltree.model.treePathFromNode(node);",
1044           "        print(\"got tree path %s\\n\", tp);",
1045           "        if (tp != \"\") {",
1046           "\t         ",
1047           "\t       ",
1048           "\t        //print(\"changing cursor on tree..\\n\");",
1049           "\t       ",
1050           " ",
1051           "            ",
1052           "            // let's try allowing editing on the methods.",
1053           "            // a little klunky at present..",
1054           "            this.prop_selected = \"\";",
1055           "            if (prop != null) {",
1056           "        \t\t//see if we can find it..",
1057           "        \t\tvar kv = prop.split(\":\");",
1058           "        \t\tif (kv[0] == \"p\") {",
1059           "        \t\t",
1060           "\t        \t\t//var k = prop.get_key(kv[1]);",
1061           "\t        \t\t// fixme -- need to determine if it's an editable property...",
1062           "\t        \t\tthis.prop_selected = prop;",
1063           "\t        \t\t",
1064           "        \t\t} else if (kv[0] == \"l\") {",
1065           "        \t\t\t this.prop_selected = prop;",
1066           "        \t\t\t",
1067           "        \t\t}",
1068           "            }",
1069           "            ltree.view.setCursor(tp, \"editor\");",
1070           "           // ltree.view.el.set_cursor(new Gtk.TreePath.from_string(tp), null, false); ",
1071           "           this.nodeSelected(node,false);",
1072           "            ",
1073           "            // scrolling is disabled... as node selection calls scroll 10ms after it changes.",
1074           "             ",
1075           "        }",
1076           "        ",
1077           "        // highlight the node..",
1078           "}",
1079           " "
1080          ],
1081          "| void updateGreySelection" : [
1082           "(bool scroll) { ",
1083           "\tvar sel = this.node_selected;",
1084           "\tprint(\"node selected\\n\");",
1085           "    var buf = this.el.get_buffer();",
1086           "    var sbuf = (Gtk.SourceBuffer) buf;",
1087           "",
1088           "   ",
1089           "   this.clearGreySelection();",
1090           "   ",
1091           "   ",
1092           "   ",
1093           "     if (sel == null) {",
1094           "\t     print(\"no selected node\\n\");",
1095           "        // no highlighting..",
1096           "        return;",
1097           "    }",
1098           "    ",
1099           "    print(\"highlight region %d to %d\\n\", sel.line_start,sel.line_end);",
1100           "    Gtk.TextIter iter;   ",
1101           "    sbuf.get_iter_at_line(out iter,  sel.line_start);",
1102           "    ",
1103           "    ",
1104           "    Gtk.TextIter cur_iter;",
1105           "    sbuf.get_iter_at_offset(out cur_iter, sbuf.cursor_position);",
1106           "   ",
1107           "    var cursor_at_line = cur_iter.get_line();",
1108           "    ",
1109           "    ",
1110           "    //var cur_line = cur_iter.get_line();",
1111           "    //if (cur_line > sel.line_start && cur_line < sel.line_end) {",
1112           "    ",
1113           "    //} else {",
1114           "    if (scroll) {",
1115           "\t\tprint(\"scrolling to node -- should occur on node picking.\\n\");",
1116           "    \tthis.el.scroll_to_iter(iter,  0.1f, true, 0.0f, 0.5f);",
1117           "\t}",
1118           "    ",
1119           "    var start_line = sel.line_start;",
1120           "    var end_line = sel.line_end;",
1121           "    ",
1122           "    ",
1123           "    this.el.editable = false;",
1124           "    ",
1125           "    //var colon_pos = 0;",
1126           "    ",
1127           "    this.editable_start_pos = -1;",
1128           "    ",
1129           "    // now if we have selected a property...",
1130           "    if (this.prop_selected.length> 0 ) {",
1131           "",
1132           "\t\tint nstart, nend;",
1133           "\t\tif (sel.getPropertyRange(this.prop_selected, out nstart, out nend) && nend > nstart) {",
1134           "\t\t\tstart_line = nstart;",
1135           "\t\t\tend_line = nend;",
1136           "\t\t\tthis.el.editable = true;",
1137           "\t\t\tprint(\"start line = %d, end line = %d\\n\", start_line, end_line);",
1138           "\t\t\t",
1139           "\t\t\t\t// see if we are 'right of ':'",
1140           "\t\t\t\t// get an iter for the start of the line.",
1141           "\t\t\tGtk.TextIter start_first_line_iter,end_first_line_iter;",
1142           "\t\t\tthis.el.buffer.get_iter_at_line(out start_first_line_iter, start_line -1);",
1143           "\t\t\tthis.el.buffer.get_iter_at_line(out end_first_line_iter, start_line -1);",
1144           "\t\t\t ",
1145           "\t\t\t",
1146           "\t\t\t",
1147           "\t\t\t",
1148           "\t\t\tif (end_first_line_iter.forward_to_line_end()) {",
1149           "\t\t\t\tvar first_line  = this.el.buffer.get_text(start_first_line_iter, end_first_line_iter, false);",
1150           "\t\t\t\t",
1151           "\t\t\t\tprint(\"first line = %s\\n\", first_line);",
1152           "\t\t\t\tif (first_line.contains(\":\")) {",
1153           "\t\t\t\t\tthis.editable_start_pos = start_first_line_iter.get_offset() + first_line.index_of(\":\") + 1;",
1154           "\t\t\t\t\tprint(\"colon_pos  = %d\\n\", this.editable_start_pos);",
1155           "\t\t\t\t}",
1156           "\t\t\t\t",
1157           "",
1158           "\t\t\t\t//Gtk.TextIter colon_iter;",
1159           "\t\t\t\t//sbuf.get_iter_at_offset (out colon_iter, colon_pos);",
1160           "\t\t\t\t//sbuf.create_source_mark(null, \"active_text\", colon_iter);",
1161           "\t\t\t}",
1162           "\t\t\t",
1163           "\t\t\t",
1164           "\t\t\t",
1165           "\t\t\t//print(\"is cursor at line? %d ?= %d\\n\", start_line -1 , cursor_at_line);",
1166           "\t\t\t//if (start_line - 1 == cursor_at_line) {",
1167           "\t\t\t// should be ok - current_posssion can not be less than '-1'...",
1168           "\t\t\tif (sbuf.cursor_position < this.editable_start_pos) {",
1169           "\t\t\t",
1170           "\t\t\t\tprint(\"cursor is before start pos.. - turn off editable...\\n\");",
1171           "\t\t\t\t//var before_cursor_string = this.el.buffer.get_text(start_line_iter, cur_iter, false);",
1172           "\t\t\t\t//print(\"before cursor string =  %s\\n\", before_cursor_string);",
1173           "\t\t\t\t//if (!before_cursor_string.contains(\":\")) {",
1174           "\t\t\t\t\tthis.el.editable = false;",
1175           "\t\t\t\t//}",
1176           "\t\t\t\t",
1177           "\t\t\t}",
1178           "\t\t\t ",
1179           "\t\t\t ",
1180           "",
1181           "\t\t\t ",
1182           "\t\t}",
1183           "\t\tprint(\"propSelected = %s range  %d -> %d\\n\", this.prop_selected, start_line, end_line);\t\t",
1184           "\t\t",
1185           "\t\t",
1186           "    }",
1187           "    ",
1188           "\tprint(\"checking selection\\n\");",
1189           "    ",
1190           "    ",
1191           "    // check selection - if it's out of 'bounds'",
1192           "    if (this.el.editable && sbuf.get_has_selection()) {",
1193           "\t\tGtk.TextIter sel_start_iter, sel_end_iter;",
1194           "\t\tsbuf.get_selection_bounds(out sel_start_iter, out sel_end_iter);",
1195           "\t\t",
1196           "\t\tif (sel_start_iter.get_line() < start_line || sel_end_iter.get_line() > end_line ||",
1197           "\t\t\tsel_start_iter.get_line() > end_line   || sel_end_iter.get_line() < start_line\t\t\t) {",
1198           "\t\t\t// save?",
1199           "\t\t\tthis.el.editable = false;",
1200           "\t\t}",
1201           "\t\tif (this.editable_start_pos > 0 &&",
1202           "\t\t\t(sel_start_iter.get_offset() < this.editable_start_pos || sel_end_iter.get_offset() < this.editable_start_pos)",
1203           "\t\t\t",
1204           "\t\t) {",
1205           "\t\t\tthis.el.editable = false;",
1206           "\t\t}",
1207           "\t\t",
1208           "\t\t ",
1209           "    ",
1210           "    }",
1211           "    ",
1212           "    ",
1213           "    ",
1214           "    ",
1215           "    for (var i = 0; i < buf.get_line_count();i++) {",
1216           "        if (i < (start_line -1) || i > (end_line -1)) {",
1217           "           ",
1218           "            sbuf.get_iter_at_line(out iter, i);",
1219           "            sbuf.create_source_mark(null, \"grey\", iter);",
1220           "            ",
1221           "        }",
1222           "    ",
1223           "    }",
1224           "    if (scroll && (cursor_at_line > end_line || cursor_at_line < start_line)) {",
1225           "\t    Gtk.TextIter cpos_iter;",
1226           "\t\tbuf.get_iter_at_line(out cpos_iter, start_line);",
1227           "\t\t",
1228           "\t\tbuf.place_cursor(cpos_iter); ",
1229           "\t}",
1230           "",
1231           "",
1232           "}"
1233          ]
1234         }
1235        ],
1236        "xtype" : "ScrolledWindow"
1237       }
1238      ],
1239      "xtype" : "Notebook"
1240     }
1241    ],
1242    "xtype" : "Box",
1243    "| int search" : [
1244     "(string txt) {",
1245     "\tthis.notebook.el.page = 1;",
1246     " \tvar s = new Gtk.SourceSearchSettings();",
1247     "\tvar buf = (Gtk.SourceBuffer) this.sourceview.el.get_buffer();",
1248     "\tthis.searchcontext = new Gtk.SourceSearchContext(buf,s);",
1249     "\tthis.searchcontext.set_highlight(true);",
1250     "\ts.set_search_text(txt);",
1251     "\t",
1252     "\tGtk.TextIter beg, st,en;",
1253     "\t ",
1254     "\tbuf.get_start_iter(out beg);",
1255     "\tthis.searchcontext.forward(beg, out st, out en);",
1256     "\tthis.last_search_end  = 0;",
1257     "\treturn this.searchcontext.get_occurrences_count();",
1258     "",
1259     "   ",
1260     "}",
1261     ""
1262    ],
1263    "| void createThumb" : [
1264     "() {",
1265     "    ",
1266     "    ",
1267     "    if (this.file == null) {",
1268     "        return;",
1269     "    }",
1270     "\tif (this.notebook.el.page > 0 ) {",
1271     "        return;",
1272     "    }",
1273     "    ",
1274     "    var filename = this.file.getIconFileName(false);",
1275     "    ",
1276     "    var  win = this.el.get_parent_window();",
1277     "    var width = win.get_width();",
1278     "  //  var height = win.get_height();",
1279     "    try { ",
1280     "        Gdk.Pixbuf screenshot = Gdk.pixbuf_get_from_window(win, 0, 0, width, this.paned.el.position);",
1281     "        screenshot.save(filename,\"png\");",
1282     "    } catch(Error e) {",
1283     "        //noop",
1284     "    }",
1285     "",
1286     "    ",
1287     "     ",
1288     "    ",
1289     "     ",
1290     "}",
1291     ""
1292    ],
1293    "| void forwardSearch" : [
1294     "(bool change_focus) {",
1295     "",
1296     "\tif (this.searchcontext == null) {",
1297     "\t\treturn;",
1298     "\t}",
1299     "\tthis.notebook.el.page = 1;",
1300     "\tGtk.TextIter beg, st,en, stl;",
1301     "\t",
1302     "\tvar buf = this.sourceview.el.get_buffer();",
1303     "\tbuf.get_iter_at_offset(out beg, this.last_search_end);",
1304     "\tif (!this.searchcontext.forward(beg, out st, out en)) {",
1305     "\t\tthis.last_search_end = 0;",
1306     "\t\treturn;",
1307     "\t}",
1308     "\tthis.last_search_end = en.get_offset();",
1309     "\tif (change_focus) {",
1310     "\t\tthis.sourceview.el.grab_focus();",
1311     "\t}",
1312     "\tbuf.place_cursor(st);",
1313     "\tvar ln = st.get_line();",
1314     "\tbuf.get_iter_at_line(out stl,ln);",
1315     "\t ",
1316     "\tthis.sourceview.el.scroll_to_iter(stl,  0.0f, true, 0.0f, 0.5f);",
1317     "\t",
1318     "\t// highlight node...",
1319     "\t",
1320     "\t\t",
1321     "    var node = _this.file.lineToNode(ln+1);",
1322     " ",
1323     "    if (node == null) {",
1324     "        //print(\"can not find node\\n\");",
1325     "        return;",
1326     "    }",
1327     "    var prop = node.lineToProp(ln+1);",
1328     "    print(\"prop : %s\", prop == null ? \"???\" : prop);",
1329     "        ",
1330     "        ",
1331     "    // ---------- this selects the tree's node...",
1332     "    ",
1333     "    var ltree = _this.main_window.windowstate.left_tree;",
1334     "    var tp = ltree.model.treePathFromNode(node);",
1335     "    print(\"got tree path %s\\n\", tp);",
1336     "    if (tp == \"\") {",
1337     "\t\treturn;",
1338     "\t}",
1339     "    //_this.sourceview.allow_node_scroll = false; /// block node scrolling..",
1340     "\t       ",
1341     "   ",
1342     "    //print(\"changing cursor on tree..\\n\");",
1343     "   ",
1344     "",
1345     "    ",
1346     "    // let's try allowing editing on the methods.",
1347     "    // a little klunky at present..",
1348     "\t_this.sourceview.prop_selected = \"\";",
1349     "    if (prop != null) {",
1350     "\t\t//see if we can find it..",
1351     "\t\tvar kv = prop.split(\":\");",
1352     "\t\tif (kv[0] == \"p\") {",
1353     "\t\t",
1354     "    \t\t//var k = prop.get_key(kv[1]);",
1355     "    \t\t// fixme -- need to determine if it's an editable property...",
1356     "    \t\t_this.sourceview.prop_selected = prop;",
1357     "    \t\t",
1358     "\t\t} else if (kv[0] == \"l\") {",
1359     "\t\t\t _this.sourceview.prop_selected = prop;",
1360     "\t\t\t",
1361     "\t\t}",
1362     "    }",
1363     "    ltree.view.setCursor(tp, \"editor\");",
1364     "   // ltree.view.el.set_cursor(new Gtk.TreePath.from_string(tp), null, false); ",
1365     "   _this.sourceview.nodeSelected(node,false);",
1366     "    ",
1367     "            // scrolling is disabled... as node selection calls scroll 10ms after it changes.",
1368     "      //      GLib.Timeout.add_full(GLib.Priority.DEFAULT,100 , () => {",
1369     "\t  //          this.allow_node_scroll = true;",
1370     "\t  //          return false;",
1371     "      //      });",
1372     "      //  }",
1373     "\t\t",
1374     "\t\t",
1375     "\t\t",
1376     "\t\t",
1377     "\t\t",
1378     "\t\t",
1379     "\t\t",
1380     "\t\t",
1381     "\t\t",
1382     "\t\t ",
1383     "",
1384     "}",
1385     ""
1386    ],
1387    "| void loadFile" : [
1388     "",
1389     "(JsRender.JsRender file)",
1390     "{",
1391     "    this.file = file;",
1392     "    this.view.renderJS(true);",
1393     "    this.notebook.el.page = 0;// gtk preview ",
1394     "    this.sourceview.loadFile();   ",
1395     "    ",
1396     "}",
1397     " ",
1398     " "
1399    ],
1400    "| void requestRedraw" : [
1401     "() {",
1402     "    this.view.renderJS(false);",
1403     "    this.sourceview.loadFile();   ",
1404     "}"
1405    ],
1406    "| void scroll_to_line" : [
1407     "(int line) {",
1408     "   this.notebook.el.page = 1;// code preview...",
1409     "   ",
1410     "   GLib.Timeout.add(500, () => {",
1411     "   ",
1412     "   ",
1413     "\t   ",
1414     "\t   ",
1415     "\t\t  var buf = this.sourceview.el.get_buffer();",
1416     "\t ",
1417     "\t\tvar sbuf = (Gtk.SourceBuffer) buf;",
1418     "",
1419     "",
1420     "\t\tGtk.TextIter iter;   ",
1421     "\t\tsbuf.get_iter_at_line(out iter,  line);",
1422     "\t\tthis.sourceview.el.scroll_to_iter(iter,  0.1f, true, 0.0f, 0.5f);",
1423     "\t\treturn false;",
1424     "\t});   ",
1425     "",
1426     "   ",
1427     "}",
1428     ""
1429    ]
1430   }
1431  ],
1432  "modOrder" : "",
1433  "name" : "WindowRooView",
1434  "parent" : "",
1435  "path" : "/home/alan/gitlive/roobuilder/src/Builder4/WindowRooView.bjs",
1436  "permname" : "",
1437  "title" : ""
1438 }