meson.build.o7QLX02
[roobuilder] / src / Builder4 / GtkView.bjs
1 {
2  "build_module" : "builder",
3  "gen_extended" : false,
4  "items" : [
5   {
6    "# Gtk.Widget lastObj" : "null",
7    "# GtkSource.SearchContext searchcontext" : "",
8    "# JsRender.JsRender file" : "null",
9    "# Xcls_MainWindow main_window" : "",
10    "$ xns" : "Gtk",
11    "* init" : [
12     "{",
13     "",
14     "\tthis.css = new Gtk.CssProvider();",
15     "\t ",
16     "\tthis.css.load_from_string(",
17     "\t\t\"#gtkview-view-layout { background-color: #ccc; }\"",
18     "\t);",
19     "\t ",
20     "\tGtk.StyleContext.add_provider_for_display(",
21     "\t\tthis.el.get_display(),",
22     "\t\tthis.css,",
23     "\t\tGtk.STYLE_PROVIDER_PRIORITY_APPLICATION",
24     "\t);",
25     "\t\t",
26     "        ",
27     "}",
28     ""
29    ],
30    "Gtk.CssProvider css" : "",
31    "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
32    "bool hexpand" : true,
33    "bool vexpand" : true,
34    "id" : "GtkView",
35    "int last_search_end" : 0,
36    "items" : [
37     {
38      "$ xns" : "Gtk",
39      "Gtk.Overflow overflow" : "Gtk.Overflow.VISIBLE",
40      "id" : "notebook",
41      "items" : [
42       {
43        "$ xns" : "Gtk",
44        "* pack" : false,
45        "id" : "label_preview",
46        "utf8 label" : "Preview",
47        "xtype" : "Label"
48       },
49       {
50        "$ xns" : "Gtk",
51        "* pack" : false,
52        "id" : "label_code",
53        "utf8 label" : "Preview Generated Code",
54        "xtype" : "Label"
55       },
56       {
57        "$ xns" : "Gtk",
58        "* pack" : "append_page,_this.label_preview.el",
59        "items" : [
60         {
61          "$ xns" : "Gtk",
62          "* pack" : "set_child",
63          "id" : "view_layout",
64          "items" : [
65           {
66            "$ xns" : "Gtk",
67            "* pack" : "put,10,10",
68            "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
69            "id" : "container",
70            "xtype" : "Box"
71           }
72          ],
73          "string name" : "gtkview-view-layout",
74          "xtype" : "Fixed"
75         }
76        ],
77        "xtype" : "ScrolledWindow"
78       },
79       {
80        "$ xns" : "Gtk",
81        "* pack" : "append_page,_this.label_code.el",
82        "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
83        "int spacing" : 0,
84        "items" : [
85         {
86          "$ xns" : "Gtk",
87          "bool vexpand" : true,
88          "id" : "sourceviewscroll",
89          "items" : [
90           {
91            "# JsRender.Node? node_selected" : "",
92            "# string prop_selected" : "\"\"",
93            "$ xns" : "GtkSource",
94            "* init" : [
95             "{",
96             "   ",
97             "   ",
98             "   \tthis.css = new Gtk.CssProvider();",
99             "\t ",
100             "\tthis.css.load_from_string(\"#gtkview-view { font: 10px monospace ;}\");",
101             "\t ",
102             "\tGtk.StyleContext.add_provider_for_display(",
103             "\t\tthis.el.get_display(),",
104             "\t\tthis.css,",
105             "\t\tGtk.STYLE_PROVIDER_PRIORITY_APPLICATION",
106             "\t);",
107             "\t\t",
108             "\t\t ",
109             "    this.loading = true;",
110             "    ",
111             "  ",
112             "  ",
113             "    var attrs = new GtkSource.MarkAttributes();",
114             "    var  pink =   Gdk.RGBA();",
115             "    pink.parse ( \"pink\");",
116             "    attrs.set_background ( pink);",
117             "    attrs.set_icon_name ( \"process-stop\");    ",
118             "    attrs.query_tooltip_text.connect(( mark) => {",
119             "        //print(\"tooltip query? %s\\n\", mark.name);",
120             "        return mark.name;",
121             "    });",
122             "    ",
123             "    this.el.set_mark_attributes (\"ERR\", attrs, 1);",
124             "    ",
125             "     var wattrs = new GtkSource.MarkAttributes();",
126             "    var  blue =   Gdk.RGBA();",
127             "    blue.parse ( \"#ABF4EB\");",
128             "    wattrs.set_background ( blue);",
129             "    wattrs.set_icon_name ( \"process-stop\");    ",
130             "    wattrs.query_tooltip_text.connect(( mark) => {",
131             "        //print(\"tooltip query? %s\\n\", mark.name);",
132             "        return mark.name;",
133             "    });",
134             "    ",
135             "    this.el.set_mark_attributes (\"WARN\", wattrs, 1);",
136             "    ",
137             " ",
138             "    ",
139             "     var dattrs = new GtkSource.MarkAttributes();",
140             "    var  purple =   Gdk.RGBA();",
141             "    purple.parse ( \"#EEA9FF\");",
142             "    dattrs.set_background ( purple);",
143             "    dattrs.set_icon_name ( \"process-stop\");    ",
144             "    dattrs.query_tooltip_text.connect(( mark) => {",
145             "        //print(\"tooltip query? %s\\n\", mark.name);",
146             "        return mark.name;",
147             "    });",
148             "    ",
149             "    this.el.set_mark_attributes (\"DEPR\", dattrs, 1);",
150             "    ",
151             "    ",
152             "    var gattrs = new GtkSource.MarkAttributes();",
153             "    var  grey =   Gdk.RGBA();",
154             "    grey.parse ( \"#ccc\");",
155             "    gattrs.set_background ( grey);",
156             " ",
157             "    ",
158             "    this.el.set_mark_attributes (\"grey\", gattrs, 1);",
159             "    ",
160             "    ",
161             "    ",
162             "    ",
163             "    ",
164             "    ",
165             "}",
166             " "
167            ],
168            "* pack" : "set_child",
169            "Gtk.CssProvider css" : "",
170            "bool loading" : false,
171            "bool zallow_node_scroll" : true,
172            "gboolean editable" : false,
173            "gboolean show_line_marks" : true,
174            "gboolean show_line_numbers" : true,
175            "id" : "sourceview",
176            "items" : [
177             {
178              "$ xns" : "GtkSource",
179              "* pack" : "set_buffer",
180              "bool dirty" : false,
181              "bool in_cursor_change" : false,
182              "id" : "buffer",
183              "int error_line" : "-1",
184              "int last_line" : "-1",
185              "listeners" : {
186               "cursor_moved" : [
187                "( ) => {",
188                "GLib.debug(\"cursor moved called\");",
189                "",
190                "",
191                " \tif (this.in_cursor_change ) {",
192                "        GLib.debug(\"cursor changed : %d [ignoring nested call)\", this.el.cursor_position);",
193                "        return;",
194                "    }",
195                "   ",
196                "    GLib.debug(\"cursor changed : %d\", this.el.cursor_position);",
197                "    Gtk.TextIter cpos;",
198                "    this.el.get_iter_at_offset(out cpos, this.el.cursor_position);",
199                "    ",
200                "    var ln = cpos.get_line();",
201                "    if (this.last_line == ln ){",
202                "    \treturn;",
203                "\t}",
204                "\tthis.last_line = ln;",
205                "    var node = _this.file.lineToNode(ln);",
206                "",
207                "    if (node == null) {",
208                "        print(\"can not find node\\n\");",
209                "        return;",
210                "    }",
211                "    this.in_cursor_change  = true;",
212                "    var ltree = _this.main_window.windowstate.left_tree;",
213                "    ltree.model.selectNode(node);",
214                "    this.in_cursor_change  = false;",
215                "}",
216                ""
217               ]
218              },
219              "xtype" : "Buffer"
220             },
221             {
222              "$ xns" : "Gtk",
223              "listeners" : {
224               "key_pressed" : [
225                "(keyval, keycode, state) => {",
226                "",
227                "\t",
228                "\t ",
229                "\t if (keyval == Gdk.Key.g && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {",
230                "\t    GLib.debug(\"SAVE: ctrl-g  pressed\");",
231                "\t\t_this.forwardSearch(true);",
232                "\t    return true;",
233                "\t}",
234                "    if (keyval == Gdk.Key.f && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {",
235                "\t    GLib.debug(\"SAVE: ctrl-f  pressed\");",
236                "\t\t_this.search_entry.el.grab_focus();",
237                "\t    return true;",
238                "\t}",
239                "\t ",
240                "\treturn false;",
241                "}\t ",
242                "\t"
243               ]
244              },
245              "xtype" : "EventControllerKey"
246             }
247            ],
248            "listeners" : {
249             "query_tooltip" : [
250              "(x, y, keyboard_tooltip, tooltip) => {",
251              "\t",
252              "\t//GLib.debug(\"query tooltip\");",
253              "\tGtk.TextIter iter;",
254              "\tint trailing;",
255              "\t",
256              "\tvar yoff = (int) _this.sourceviewscroll.el.vadjustment.value;",
257              "\t",
258              "\tthis.el.get_iter_at_position (out iter, out trailing,  x,  y + yoff);",
259              "\t ",
260              "\tvar l = iter.get_line();",
261              "\t// GLib.debug(\"query tooltip line %d\", (int) l);",
262              "\tvar marks = _this.buffer.el.get_source_marks_at_line(l, \"ERR\");",
263              "\tif (marks.is_empty()) {",
264              "\t\tmarks = _this.buffer.el.get_source_marks_at_line(l, \"WARN\");",
265              "\t}",
266              "\tif (marks.is_empty()) {",
267              "\t\tmarks = _this.buffer.el.get_source_marks_at_line(l, \"DEPR\");",
268              "\t}",
269              "\t",
270              "\t// GLib.debug(\"query tooltip line marks %d\", (int) marks.length());",
271              "\tvar str = \"\";",
272              "\tmarks.@foreach((m) => { ",
273              "\t\t//GLib.debug(\"got mark %s\", m.name);",
274              "\t\tstr += (str.length > 0 ? \"\\n\" : \"\") + m.name;",
275              "\t});",
276              "\t",
277              "\t// true if there is a mark..",
278              "\ttooltip.set_text( str);",
279              "\treturn str.length > 0 ? true : false;",
280              "",
281              "}",
282              ""
283             ]
284            },
285            "string name" : "gtkview-view",
286            "uint tab_width" : 4,
287            "xtype" : "View",
288            "| string toString" : [
289             "() {",
290             "   Gtk.TextIter s;",
291             "    Gtk.TextIter e;",
292             "    this.el.get_buffer().get_start_iter(out s);",
293             "    this.el.get_buffer().get_end_iter(out e);",
294             "    var ret = this.el.get_buffer().get_text(s,e,true);",
295             "    //print(\"TO STRING? \" + ret);",
296             "    return ret;",
297             "}",
298             ""
299            ],
300            "| void loadFile" : [
301             "( ) {",
302             "    this.loading = true;",
303             "    var buf = this.el.get_buffer();",
304             "    buf.set_text(\"\",0);",
305             "    var sbuf = (GtkSource.Buffer) buf;",
306             "\tvar cpos = buf.cursor_position;",
307             "    ",
308             "   \tprint(\"BEFORE LOAD cursor = %d\\n\", cpos);",
309             "        var vadj_pos = this.el.get_vadjustment().get_value();",
310             "",
311             "    if (_this.file == null || _this.file.xtype != \"Gtk\") {",
312             "        print(\"xtype != Gtk\");",
313             "        this.loading = false;",
314             "        return;",
315             "    }",
316             "    ",
317             "    var valafn = \"\";",
318             "      try {             ",
319             "           var  regex = new Regex(\"\\\\.bjs$\");",
320             "        ",
321             "         ",
322             "            valafn = regex.replace(_this.file.path,_this.file.path.length , 0 , \".vala\");",
323             "         } catch (GLib.RegexError e) {",
324             "             this.loading = false;",
325             "            return;",
326             "        }   ",
327             "    ",
328             "",
329             "   if (!FileUtils.test(valafn,FileTest.IS_REGULAR) ) {",
330             "        print(\"File path has no errors\\n\");",
331             "        this.loading = false;",
332             "        return  ;",
333             "    }",
334             "    ",
335             "    string str;",
336             "    try {",
337             "    ",
338             "        GLib.FileUtils.get_contents (valafn, out str);",
339             "    } catch (Error e) {",
340             "        this.loading = false;",
341             "        return  ;",
342             "    }",
343             "",
344             "//    print(\"setting str %d\\n\", str.length);",
345             "    buf.set_text(str, str.length);",
346             "    var lm = GtkSource.LanguageManager.get_default();",
347             "     ",
348             "    //?? is javascript going to work as js?",
349             "    ",
350             "    ((GtkSource.Buffer)(buf)) .set_language(lm.get_language(_this.file.language));",
351             "  ",
352             "     ",
353             "   _this.main_window.windowstate.updateErrorMarksAll(); ",
354             "   //  restore the cursor position?",
355             "    // after reloading the contents.",
356             "     GLib.Timeout.add(500, () => {",
357             "\t\t_this.buffer.in_cursor_change = true;",
358             "        print(\"RESORTING cursor to = %d\\n\", cpos);",
359             "\t\tGtk.TextIter cpos_iter;",
360             "\t\tbuf.get_iter_at_offset(out cpos_iter, cpos);",
361             "\t\tbuf.place_cursor(cpos_iter); ",
362             "\t\t",
363             "\t\tthis.el.get_vadjustment().set_value(vadj_pos);;",
364             "\t\t_this.buffer.in_cursor_change = false;",
365             " ",
366             "\t\t",
367             "\t\t",
368             "\t\t//_this.buffer.checkSyntax();",
369             "\t\treturn false;",
370             "\t});",
371             "  ",
372             "    ",
373             "    this.loading = false; ",
374             "}",
375             ""
376            ],
377            "| void nodeSelected" : [
378             "(JsRender.Node? sel, bool scroll) {",
379             "  ",
380             "    ",
381             "    if (this.loading) {",
382             "    \treturn;",
383             "\t}",
384             "    // this is connected in widnowstate",
385             "    print(\"Roo-view - node selected\\n\");",
386             "    var buf = this.el.get_buffer();",
387             " ",
388             "    var sbuf = (GtkSource.Buffer) buf;",
389             "",
390             "   ",
391             " ",
392             "    ",
393             "   ",
394             "    // clear all the marks..",
395             "     Gtk.TextIter start;",
396             "    Gtk.TextIter end;     ",
397             "        ",
398             "    sbuf.get_bounds (out start, out end);",
399             "    sbuf.remove_source_marks (start, end, \"grey\");",
400             "    ",
401             "        this.node_selected = sel;",
402             "     if (sel == null) {",
403             "        // no highlighting..",
404             "        return;",
405             "    }",
406             "    Gtk.TextIter iter;   ",
407             "    sbuf.get_iter_at_line(out iter,  sel.line_start);",
408             "    ",
409             "    ",
410             "    Gtk.TextIter cur_iter;",
411             "    sbuf.get_iter_at_offset(out cur_iter, sbuf.cursor_position);",
412             "    ",
413             "    ",
414             "    if (!_this.buffer.in_cursor_change) {",
415             "",
416             "    \tthis.el.scroll_to_iter(iter,  0.1f, true, 0.0f, 0.5f);",
417             "\t}  ",
418             "    ",
419             "     ",
420             "    ",
421             "    for (var i = 0; i < buf.get_line_count();i++) {",
422             "        if (i < sel.line_start || i > sel.line_end) {",
423             "           ",
424             "            sbuf.get_iter_at_line(out iter, i);",
425             "            sbuf.create_source_mark(null, \"grey\", iter);",
426             "            ",
427             "        }",
428             "    ",
429             "    }",
430             "    ",
431             "",
432             "}",
433             ""
434            ]
435           }
436          ],
437          "xtype" : "ScrolledWindow"
438         },
439         {
440          "$ xns" : "Gtk",
441          "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
442          "bool homogeneous" : false,
443          "bool vexpand" : false,
444          "int spacing" : 0,
445          "items" : [
446           {
447            "$ xns" : "Gtk",
448            "* init" : [
449             " ",
450             "this.css = new Gtk.CssProvider();",
451             "",
452             "this.css.load_from_string(\"",
453             "\t#gtkview-search-entry { font: 10px monospace ;}\"",
454             ");",
455             "",
456             "Gtk.StyleContext.add_provider_for_display(",
457             "\tthis.el.get_display(),",
458             "\tthis.css,",
459             "\tGtk.STYLE_PROVIDER_PRIORITY_APPLICATION",
460             ");",
461             "\t\t",
462             "",
463             ""
464            ],
465            "Gtk.CssProvider css" : "",
466            "bool hexpand" : true,
467            "id" : "search_entry",
468            "items" : [
469             {
470              "$ xns" : "Gtk",
471              "listeners" : {
472               "key_pressed" : [
473                "(keyval, keycode, state) => {",
474                "",
475                "\tif (keyval == Gdk.Key.g && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {",
476                "\t    GLib.debug(\"SAVE: ctrl-g  pressed\");",
477                "\t\t_this.forwardSearch(true);",
478                "\t    return true;",
479                "\t}",
480                "    ",
481                "  ",
482                " \tif (keyval == Gdk.Key.Return && _this.search_entry.el.text.length > 0) {",
483                "\t\t_this.forwardSearch(true);",
484                "\t\t",
485                "\t\t",
486                "\t    return true;",
487                "",
488                "\t}    ",
489                "   // print(event.key.keyval)",
490                "   ",
491                "    return false;",
492                "}",
493                ""
494               ]
495              },
496              "xtype" : "EventControllerKey"
497             }
498            ],
499            "listeners" : {
500             "search_changed" : [
501              " () => {",
502              "  \t ",
503              "\t_this.search(_this.search_entry.el.text);",
504              "\t _this.search_results.updateResults();",
505              "",
506              "\tGLib.Timeout.add_seconds(1,() => {",
507              "\t\t _this.search_results.updateResults();",
508              "\t\t return false;",
509              "\t });",
510              "\t  ",
511              "   ",
512              "    ",
513              "}"
514             ]
515            },
516            "string name" : "gtkview-search-entry",
517            "string placeholder_text" : "Press enter to search",
518            "uint search_delay" : 3,
519            "xtype" : "SearchEntry",
520            "| void forwardSearch" : [
521             "(bool change_focus) {",
522             "",
523             "",
524             "\t_this.forwardSearch(change_focus);",
525             "",
526             "/*",
527             "",
528             "\tswitch(_this.windowstate.state) {",
529             "\t\tcase WindowState.State.CODEONLY:",
530             "\t\t//case WindowState.State.CODE:",
531             "\t\t\t// search the code being edited..",
532             "\t\t\t_this.windowstate.code_editor_tab.forwardSearch(change_focus);",
533             "\t\t\t ",
534             "\t\t\tbreak;",
535             "\t\tcase WindowState.State.PREVIEW:",
536             "\t\t\tif (_this.windowstate.file.xtype == \"Gtk\") {",
537             "\t\t\t\t_this.windowstate.window_gladeview.forwardSearch(change_focus);",
538             "\t\t\t} else { ",
539             "\t\t\t\t _this.windowstate.window_rooview.forwardSearch(change_focus);",
540             "\t\t\t}",
541             "\t\t",
542             "\t\t\tbreak;",
543             "\t}",
544             "\t*/",
545             "\t",
546             "}",
547             ""
548            ]
549           },
550           {
551            "$ xns" : "Gtk",
552            "id" : "search_results",
553            "int margin_end" : 4,
554            "int margin_start" : 4,
555            "string label" : "No Results",
556            "xtype" : "Label",
557            "| void updateResults" : [
558             "() {",
559             "\tthis.el.visible = true;",
560             "\t",
561             "\tvar res = _this.searchcontext.get_occurrences_count();",
562             "\tif (res < 0) {",
563             "\t\t_this.search_results.el.label = \"??? Matches\";\t\t",
564             "\t\treturn;",
565             "\t}",
566             "",
567             "\t_this.nextBtn.el.sensitive = false;",
568             "\t_this.backBtn.el.sensitive = false;\t",
569             "",
570             "\tif (res > 0) {",
571             "\t\t_this.search_results.el.label = \"%d Matches\".printf(res);",
572             "\t\t_this.nextBtn.el.sensitive = true;",
573             "\t\t_this.backBtn.el.sensitive = true;",
574             "\t\treturn;",
575             "\t} ",
576             "\t_this.search_results.el.label = \"No Matches\";",
577             "\t",
578             "}"
579            ]
580           },
581           {
582            "$ xns" : "Gtk",
583            "bool always_show_image" : true,
584            "bool sensitive" : false,
585            "id" : "nextBtn",
586            "listeners" : {
587             "clicked" : [
588              "( ) => {",
589              "_this.forwardSearch(true);",
590              "\t ",
591              "",
592              "}",
593              ""
594             ]
595            },
596            "string icon_name" : "go-down",
597            "xtype" : "Button"
598           },
599           {
600            "$ xns" : "Gtk",
601            "bool always_show_image" : true,
602            "bool sensitive" : false,
603            "id" : "backBtn",
604            "listeners" : {
605             "clicked" : [
606              "( ) => {",
607              "",
608              "_this.backSearch(true);",
609              "\t",
610              "}",
611              ""
612             ]
613            },
614            "string icon_name" : "go-up",
615            "xtype" : "Button"
616           },
617           {
618            "$ xns" : "Gtk",
619            "bool always_show_arrow" : true,
620            "bool always_show_image" : true,
621            "items" : [
622             {
623              "$ xns" : "Gtk",
624              "* ctor" : "new Gtk.PopoverMenu.from_model(null)",
625              "* prop" : "popover",
626              "id" : "search_settings",
627              "items" : [
628               {
629                "$ xns" : "Gtk",
630                "* pack" : "set_child",
631                "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
632                "int spacing" : 0,
633                "items" : [
634                 {
635                  "$ xns" : "Gtk",
636                  "id" : "case_sensitive",
637                  "string label" : "Case Sensitive",
638                  "xtype" : "CheckButton"
639                 },
640                 {
641                  "$ xns" : "Gtk",
642                  "id" : "regex",
643                  "string label" : "Regex",
644                  "xtype" : "CheckButton"
645                 },
646                 {
647                  "$ xns" : "Gtk",
648                  "id" : "multiline",
649                  "string label" : "Multi-line (add \\n)",
650                  "xtype" : "CheckButton"
651                 }
652                ],
653                "xtype" : "Box"
654               }
655              ],
656              "xtype" : "PopoverMenu"
657             }
658            ],
659            "string icon_name" : "emblem-system",
660            "xtype" : "MenuButton"
661           }
662          ],
663          "xtype" : "Box"
664         }
665        ],
666        "xtype" : "Box"
667       }
668      ],
669      "xtype" : "Notebook"
670     }
671    ],
672    "xtype" : "Box",
673    "| int search" : [
674     "(string in_txt) {",
675     "\tthis.notebook.el.page = 1;",
676     "\t",
677     " ",
678     "   ",
679     "\tvar s = new GtkSource.SearchSettings();",
680     "\ts.case_sensitive = _this.case_sensitive.el.active;",
681     "\ts.regex_enabled = _this.regex.el.active;\t",
682     "\ts.wrap_around = false;",
683     "\t",
684     "\tthis.searchcontext = new GtkSource.SearchContext(this.buffer.el,s);",
685     "\tthis.searchcontext.set_highlight(true);",
686     "\tvar txt = in_txt;",
687     "\t",
688     "\tif (_this.multiline.el.active) {",
689     "\t\ttxt = in_txt.replace(\"\\\\n\", \"\\n\");",
690     "\t}",
691     "\t",
692     "\ts.set_search_text(txt);",
693     "\tGtk.TextIter beg, st,en;",
694     "\tbool has_wrapped_around;",
695     "\tthis.buffer.el.get_start_iter(out beg);",
696     "\tthis.searchcontext.forward(beg, out st, out en, out has_wrapped_around);",
697     "\tthis.last_search_end = 0;",
698     "\t",
699     "\treturn this.searchcontext.get_occurrences_count();",
700     "",
701     " ",
702     "    ",
703     "",
704     "}",
705     ""
706    ],
707    "| void backSearch" : [
708     "(bool change_focus) {",
709     "",
710     "\tif (this.searchcontext == null) {",
711     "\t\treturn;",
712     "\t} ",
713     "\t",
714     "\tGtk.TextIter beg, st,en;",
715     "\tbool has_wrapped_around;",
716     "\tthis.buffer.el.get_iter_at_offset(out beg, this.last_search_end -1 );",
717     "\t",
718     "\tif (!this.searchcontext.backward(beg, out st, out en, out has_wrapped_around)) {",
719     "\t",
720     "\t\tthis.last_search_end = 0;",
721     "\t\treturn;",
722     "\t}",
723     "\tthis.last_search_end = en.get_offset();",
724     "\tif (change_focus) {",
725     "\t\tthis.sourceview.el.grab_focus();",
726     "\t}",
727     "\tthis.buffer.el.place_cursor(st);",
728     "\tthis.sourceview.el.scroll_to_iter(st,  0.1f, true, 0.0f, 0.5f);",
729     "\tvar ln = st.get_line();",
730     "\tthis.highlightNodeAtLine(ln);",
731     "\t ",
732     "}",
733     ""
734    ],
735    "| void createThumb" : [
736     "() {",
737     "    ",
738     "    ",
739     "    if (this.file == null) {",
740     "        return;",
741     "    }",
742     "    // only screenshot the gtk preview..",
743     "    if (this.notebook.el.page > 0 ) {",
744     "        return;",
745     "    }",
746     "    ",
747     "    ",
748     " \tthis.file.widgetToIcon(this.container.el); ",
749     "",
750     "    ",
751     "    return;",
752     "    ",
753     "    ",
754     "     ",
755     "     ",
756     "    ",
757     "    // should we hold until it's printed...",
758     "     ",
759     "",
760     "    ",
761     "     ",
762     "}",
763     ""
764    ],
765    "| void forwardSearch" : [
766     "(bool change_focus) {",
767     "",
768     "\tif (this.searchcontext == null) {",
769     "\t\treturn;",
770     "\t}",
771     "\tthis.notebook.el.page = 1;",
772     "\tGtk.TextIter beg, st,en;",
773     "\tbool has_wrapped_around;",
774     "\tvar buf = this.sourceview.el.get_buffer();",
775     "\tbuf.get_iter_at_offset(out beg, this.last_search_end);",
776     "\tif (!this.searchcontext.forward(beg, out st, out en, out has_wrapped_around)) {",
777     "\t\tthis.last_search_end = 0;",
778     "\t\treturn;",
779     "\t}",
780     "\tthis.last_search_end = en.get_offset();",
781     "\tif (change_focus) {",
782     "\t\tthis.sourceview.el.grab_focus();",
783     "\t}",
784     "\tbuf.place_cursor(st);",
785     "\t",
786     " ",
787     "\t ",
788     "\tthis.sourceview.el.scroll_to_iter(st,  0.0f, true, 0.0f, 0.5f);",
789     "\t",
790     "\t",
791     "\tvar ln = st.get_line();",
792     "\t",
793     "\tthis.highlightNodeAtLine(ln);",
794     "}\t",
795     "  "
796    ],
797    "| void highlightNodeAtLine" : [
798     "(int ln) {",
799     "",
800     "\t// this is done from clicking on the editor..",
801     "\t ",
802     "\t// highlight node...",
803     "\t",
804     "\t\t",
805     "    var node = _this.file.lineToNode(ln+1);",
806     " ",
807     "    if (node == null) {",
808     "        //print(\"can not find node\\n\");",
809     "        return;",
810     "    }",
811     "    var prop = node.lineToProp(ln+1);",
812     "    print(\"prop : %s\", prop == null ? \"???\" : prop.name);",
813     "        ",
814     "        ",
815     "    // ---------- this selects the tree's node...",
816     "    ",
817     "    var ltree = _this.main_window.windowstate.left_tree;",
818     "    ltree.model.selectNode(node);",
819     "    //var tp = ltree.model.treePathFromNode(node);",
820     "    ",
821     "    //print(\"got tree path %s\\n\", tp);",
822     "    //if (tp == \"\") {",
823     "\t//\treturn;",
824     "\t//}",
825     "    //_this.sourceview.allow_node_scroll = false; /// block node scrolling..",
826     "\t       ",
827     "   ",
828     "    //print(\"changing cursor on tree..\\n\");",
829     "   ",
830     "",
831     "    ",
832     "    // let's try allowing editing on the methods.",
833     "    // a little klunky at present..",
834     "\t_this.sourceview.prop_selected = \"\";",
835     "\t/*",
836     "    if (prop != null) {",
837     "\t\t//see if we can find it..",
838     "\t\tvar kv = prop.split(\":\");",
839     "\t\tif (kv[0] == \"p\") {",
840     "\t\t",
841     "    \t\t//var k = prop.get_key(kv[1]);",
842     "    \t\t// fixme -- need to determine if it's an editable property...",
843     "    \t\t_this.sourceview.prop_selected = prop;",
844     "    \t\t",
845     "\t\t} else if (kv[0] == \"l\") {",
846     "\t\t\t _this.sourceview.prop_selected = prop;",
847     "\t\t\t",
848     "\t\t}",
849     "    }",
850     "    */",
851     "    //ltree.view.setCursor(tp, \"editor\");",
852     "   // ltree.view.el.set_cursor(new Gtk.TreePath.from_string(tp), null, false); ",
853     "   _this.sourceview.nodeSelected(node,false);",
854     "    ",
855     "            // scrolling is disabled... as node selection calls scroll 10ms after it changes.",
856     "      //      GLib.Timeout.add_full(GLib.Priority.DEFAULT,100 , () => {",
857     "\t  //          this.allow_node_scroll = true;",
858     "\t  //          return false;",
859     "      //      });",
860     "      //  }",
861     "\t\t",
862     "\t\t",
863     "\t\t",
864     "\t\t",
865     "\t\t",
866     "\t\t",
867     "\t\t",
868     "\t\t",
869     "\t\t",
870     "\t\t ",
871     "",
872     "}",
873     " "
874    ],
875    "| void loadFile" : [
876     "(JsRender.JsRender file) ",
877     "{",
878     "        this.file = null;",
879     "        ",
880     "        if (file.tree == null) {",
881     "            return;",
882     "        }",
883     "        this.notebook.el.page = 0;// gtk preview ",
884     "   ",
885     "  ",
886     "        ",
887     "       this.file = file;     ",
888     "        this.sourceview.loadFile();",
889     "        this.searchcontext = null;",
890     "        ",
891     "",
892     "        if (this.lastObj != null) {",
893     "            this.container.el.remove(this.lastObj);",
894     "        }",
895     "        ",
896     "        // hide the compile view at present..",
897     "          ",
898     "        ",
899     "        var w = this.el.get_width();",
900     "        var h = this.el.get_height();",
901     "        ",
902     "        print(\"ALLOC SET SIZES %d, %d\\n\", w,h); ",
903     "        ",
904     "        // set the container size min to 500/500 or 20 px less than max..",
905     "        w = int.max (w-20, 500);",
906     "        h = int.max (h-20, 500); ",
907     "        ",
908     "        print(\"SET SIZES %d, %d\\n\", w,h);       ",
909     "        _this.container.el.set_size_request(w,h);",
910     "        ",
911     "        _this.view_layout.el.set_size_request(w,h); ",
912     "        // should be baded on calc.. -- see update_scrolled.",
913     "       ",
914     "       var fc = this.container.el.get_first_child();",
915     "       if (fc != null) {",
916     "       \t\tthis.container.el.remove(fc);",
917     "   \t\t}",
918     "        ",
919     "   \t\tvar xmlstr = JsRender.NodeToGlade.mungeFile( file);",
920     "   \t\tvar builder = new Gtk.Builder.from_string (xmlstr, xmlstr.length);",
921     "   \t\tvar obj = (Gtk.Widget) builder.get_object(\"w\"+ file.tree.oid.to_string());",
922     "   \t\t this.container.el.append(obj);",
923     "\t    obj.show();",
924     "        this.createThumb();",
925     "         ",
926     "        \t ",
927     "       return;/*",
928     "\tvar x = new JsRender.NodeToGtk((Project.Gtk) file.project, file.tree);",
929     "    var obj = x.munge() as Gtk.Widget;",
930     "    this.lastObj = null;",
931     "\tif (obj == null) {",
932     "        \treturn;",
933     "\t}",
934     "\tthis.lastObj = obj;",
935     "        ",
936     "        this.container.el.append(obj);",
937     "        obj.show();",
938     "        ",
939     "         */",
940     "        ",
941     "}",
942     " "
943    ],
944    "| void scroll_to_line" : [
945     "(int line) {",
946     "  // code preview...",
947     "   ",
948     "   GLib.Timeout.add(100, () => {",
949     "   ",
950     "   ",
951     "\t    this.notebook.el.set_current_page(1);",
952     "\t   ",
953     "\t\t  var buf = this.sourceview.el.get_buffer();",
954     "\t ",
955     "\t\tvar sbuf = (GtkSource.Buffer) buf;",
956     "",
957     "",
958     "\t\tGtk.TextIter iter;   ",
959     "\t\tsbuf.get_iter_at_line(out iter,  line);",
960     "\t\tthis.sourceview.el.scroll_to_iter(iter,  0.1f, true, 0.0f, 0.5f);",
961     "\t\treturn false;",
962     "\t});   ",
963     "",
964     "   ",
965     "}",
966     ""
967    ],
968    "| void updateErrorMarks" : [
969     "(string category) {",
970     "\t",
971     " ",
972     "",
973     "\tvar buf = _this.buffer.el;",
974     "\tGtk.TextIter start;",
975     "\tGtk.TextIter end;     ",
976     "\tbuf.get_bounds (out start, out end);",
977     "",
978     "\tbuf.remove_source_marks (start, end, category);",
979     " ",
980     "\tGLib.debug(\"highlight errors\");\t\t ",
981     "",
982     "\t // we should highlight other types of errors..",
983     "",
984     " ",
985     "",
986     "\t ",
987     "\tif (_this.file == null) {",
988     "\t\tGLib.debug(\"file is null?\");",
989     "\t\treturn;",
990     "",
991     "\t}",
992     "\tvar ar = this.file.getErrors(category);",
993     "\tif (ar == null || ar.get_n_items() < 1) {",
994     "\t\tGLib.debug(\"higjlight %s has no errors\", category);",
995     "\t\treturn;",
996     "\t}",
997     " ",
998     "",
999     " ",
1000     "\t ",
1001     "",
1002     "\tvar tlines = buf.get_line_count () +1;",
1003     "\t",
1004     " ",
1005     "\t ",
1006     "\tfor (var i = 0; i < ar.get_n_items();i++) {",
1007     "\t\tvar err = (Palete.CompileError) ar.get_item(i);",
1008     "\t\t",
1009     "\t     Gtk.TextIter iter;",
1010     "//        print(\"get inter\\n\");",
1011     "\t    var eline = err.line + 1;",
1012     "\t    GLib.debug(\"GOT ERROR on line %d -- converted to %d \",",
1013     "\t    \terr.line ,eline);",
1014     "\t    ",
1015     "\t    ",
1016     "\t    if (eline > tlines || eline < 0) {",
1017     "\t        return;",
1018     "\t    }",
1019     "\t   ",
1020     "\t    ",
1021     "\t    buf.get_iter_at_line( out iter, eline);",
1022     "\t   ",
1023     "\t   ",
1024     "\t\tvar msg = \"Line: %d %s : %s\".printf(eline+1, err.category, err.msg);",
1025     "\t    buf.create_source_mark( msg, err.category, iter);",
1026     "\t    GLib.debug(\"set line %d to %s\", eline, msg);",
1027     "\t    //this.marks.set(eline, msg);",
1028     "\t}",
1029     "\treturn ;",
1030     "",
1031     "",
1032     "",
1033     " ",
1034     "",
1035     "}"
1036    ]
1037   }
1038  ],
1039  "name" : "GtkView"
1040 }