492b2d3bc12a9578ba384e894feeda9f141f8091
[roobuilder] / src / Builder4 / Editor.bjs
1 {
2  "build_module" : "builder",
3  "gen_extended" : false,
4  "items" : [
5   {
6    "# GtkSource.SearchContext searchcontext" : "null",
7    "# JsRender.JsRender? file" : "null",
8    "# JsRender.Node node" : "null",
9    "# JsRender.NodeProp? prop" : "null",
10    "# Xcls_MainWindow window" : "null",
11    "# bool dirty" : false,
12    "# bool pos" : false,
13    "# int last_error_counter" : 0,
14    "# int pos_root_x" : "",
15    "# int pos_root_y" : "",
16    "# string activeEditor" : "\"\"",
17    "$ homogeneous" : false,
18    "$ xns" : "Gtk",
19    "@ void save" : "()",
20    "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
21    "bool hexpand" : true,
22    "bool vexpand" : true,
23    "int last_search_end" : 0,
24    "items" : [
25     {
26      "$ xns" : "Gtk",
27      "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
28      "bool resize_end_child" : false,
29      "bool resize_start_child" : false,
30      "bool shrink_end_child" : false,
31      "bool shrink_start_child" : false,
32      "id" : "paned",
33      "items" : [
34       {
35        "$ xns" : "Gtk",
36        "* prop" : "start_child",
37        "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
38        "bool hexpand" : true,
39        "int spacing" : 0,
40        "items" : [
41         {
42          "$ homogeneous" : false,
43          "$ xns" : "Gtk",
44          "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
45          "bool hexpand" : false,
46          "bool vexpand" : false,
47          "items" : [
48           {
49            "$ xns" : "Gtk",
50            "bool vexpand" : true,
51            "id" : "save_button",
52            "label" : "Save",
53            "listeners" : {
54             "clicked" : [
55              " () => { ",
56              "    _this.saveContents();",
57              "}",
58              "  "
59             ]
60            },
61            "xtype" : "Button"
62           },
63           {
64            "$ xns" : "Gtk",
65            "Gtk.Justification justify" : "Gtk.Justification.LEFT",
66            "bool hexpand" : true,
67            "float xalign" : 0,
68            "id" : "helper",
69            "int margin_end" : 4,
70            "int margin_start" : 4,
71            "items" : [
72             {
73              "$ xns" : "Gtk",
74              "listeners" : {
75               "pressed" : [
76                "(n_press, x, y) => {",
77                "\tint ix, tr;",
78                "\t_this.helper.el.get_layout().xy_to_index(x,y, out ix, out tr);",
79                "\tGLib.debug(\"label click %d\", ix);",
80                "}",
81                ""
82               ]
83              },
84              "xtype" : "GestureClick"
85             }
86            ],
87            "listeners" : {
88             "query_tooltip" : [
89              "(x, y, keyboard_tooltip, tooltip) => {",
90              "\tGLib.debug(\"using quiery tooltip?\");",
91              "\tvar lbl = new Gtk.Label(this.el.tooltip_markup);",
92              "\tlbl.width_request = 500;",
93              "\ttooltip.set_custom(lbl);",
94              "",
95              "\treturn true;",
96              "}",
97              ""
98             ]
99            },
100            "xtype" : "Label",
101            "| void setHelp" : [
102             "(Lsp.Hover? help) {",
103             "\tif (help == null || help.contents == null",
104             "\t\t|| help.contents.size < 1) {",
105             "\t\tthis.el.set_text(\"\");",
106             "\t\treturn;",
107             "\t}",
108             "\tvar sig = help.contents.get(0).value.split(\" \");",
109             "\tstring[] str = {};",
110             "\tfor(var i =0; i < sig.length; i++) {",
111             "\t",
112             "\t\tswitch(sig[i]) {",
113             "\t\t\tcase \"public\":",
114             "\t\t\tcase \"private\":",
115             "\t\t\tcase \"protected\":",
116             "\t\t\tcase \"async\":",
117             "\t\t\tcase \"class\":",
118             "\t\t\tcase \"{\":",
119             "\t\t\tcase \"}\":",
120             "\t\t\tcase \"(\":",
121             "\t\t\tcase \")\":",
122             "\t\t\t",
123             "\t\t\t\tstr += sig[i];",
124             "\t\t\t\tcontinue;",
125             "\t\t\t\t",
126             "\t\t\t\t",
127             "\t\t\tdefault:",
128             "\t",
129             "\t\t\t\tstr += (\"<span underline=\\\"single\\\" color=\\\"blue\\\" >\" + ",
130             "\t\t\t\t\tGLib.Markup.escape_text(sig[i])",
131             "\t\t\t\t\t+\"</span>\");",
132             "\t\t\tcontinue;",
133             "\t\t}",
134             "\t}",
135             "\tif (help.contents.size > 1) {",
136             "\t\tthis.el.tooltip_markup =  GLib.Markup.escape_text(help.contents.get(1).value);",
137             "\t} else {",
138             "\t\tthis.el.tooltip_markup = GLib.Markup.escape_text(help.contents.get(0).value);",
139             "\t}",
140             "\tthis.el.set_markup(string.joinv(\" \",str));",
141             "\t",
142             "}"
143            ]
144           },
145           {
146            "$ xns" : "Gtk",
147            "* ctor" : "new Gtk.Scale.with_range (Gtk.Orientation.HORIZONTAL,6, 30, 1)",
148            "* init" : [
149             "{",
150             "\t//this.el.set_range(6,30);",
151             " \tthis.el.set_value ( BuilderApplication.settings.editor_font_size);",
152             " \tBuilderApplication.settings.editor_font_size_updated.connect(",
153             " \t\t() => {",
154             " \t\t\tBuilderApplication.settings.editor_font_size_inchange = true;",
155             " \t\t//\tGLib.debug(\"update range\");",
156             " \t\t \tthis.el.set_value (BuilderApplication.settings.editor_font_size);",
157             " \t\t \tBuilderApplication.settings.editor_font_size_inchange = false;",
158             " \t\t}",
159             "\t);",
160             "\t",
161             " ",
162             "}",
163             ""
164            ],
165            "Gtk.Align halign" : "Gtk.Align.END",
166            "bool draw_value" : false,
167            "bool has_origin" : true,
168            "bool sensitive" : true,
169            "int digits" : 0,
170            "int width_request" : 150,
171            "listeners" : {
172             "change_value" : [
173              "(st, val ) => {",
174              "\tif (BuilderApplication.settings.editor_font_size_inchange) {",
175              "\t\treturn false;",
176              "\t}",
177              "  \tBuilderApplication.settings.editor_font_size = val;",
178              " \treturn false;",
179              "}"
180             ]
181            },
182            "xtype" : "Scale"
183           },
184           {
185            "$ xns" : "Gtk",
186            "Gtk.Align halign" : "Gtk.Align.END",
187            "id" : "close_btn",
188            "items" : [
189             {
190              "$ xns" : "Gtk",
191              "* prop" : "child",
192              "Gtk.IconSize icon_size" : "Gtk.IconSize.NORMAL",
193              "string icon_name" : "window-close",
194              "xtype" : "Image"
195             }
196            ],
197            "listeners" : {
198             "clicked" : [
199              " () => { ",
200              "    _this.saveContents();",
201              "    _this.window.windowstate.switchState(WindowState.State.PREVIEW);",
202              "}",
203              "  "
204             ]
205            },
206            "string icon_name" : "window-close",
207            "xtype" : "Button"
208           }
209          ],
210          "xtype" : "Box"
211         },
212         {
213          "$ xns" : "Gtk",
214          "Gtk.PolicyType hscrollbar_policy" : "Gtk.PolicyType.AUTOMATIC",
215          "Gtk.PolicyType vscrollbar_policy" : "Gtk.PolicyType.AUTOMATIC",
216          "bool overlay_scrolling" : false,
217          "bool vexpand" : true,
218          "id" : "RightEditor",
219          "items" : [
220           {
221            "# Gtk.CssProvider css" : "null",
222            "$ gboolean auto_indent" : true,
223            "$ xns" : "GtkSource",
224            "* init" : [
225             "",
226             " ",
227             "\t",
228             " ",
229             " ",
230             "this.el.completion.add_provider(",
231             "\tnew Palete.CompletionProvider(_this)",
232             ");",
233             "",
234             "// hover seems pretty useless.. - ??",
235             "//var hover = this.el.get_hover();",
236             "//hover.add_provider(new Palete.HoverProvider(_this));",
237             "",
238             "//this.el.completion.unblock_interactive();",
239             "this.el.completion.select_on_show = true; // select",
240             "//this.el.completion.remember_info_visibility\t = true;",
241             "",
242             "",
243             "var attrs = new GtkSource.MarkAttributes();",
244             "",
245             "attrs.set_icon_name ( \"process-stop\");    ",
246             "attrs.query_tooltip_text.connect(( mark) => {",
247             "     GLib.debug(\"tooltip query? %s\", mark.name);",
248             "    return strdup( mark.name);",
249             "});",
250             " attrs.query_tooltip_markup.connect(( mark) => {",
251             "     GLib.debug(\"tooltip query? %s\", mark.name);",
252             "    return strdup( mark.name);",
253             "});",
254             "this.el.set_mark_attributes (\"ERR\", attrs, 1);",
255             "attrs.ref();",
256             "",
257             "",
258             "var wattrs = new GtkSource.MarkAttributes();",
259             "wattrs.set_icon_name ( \"process-stop\");    ",
260             "wattrs.query_tooltip_text.connect(( mark) => {",
261             "     GLib.debug(\"tooltip query? %s\", mark.name);",
262             "    return strdup(mark.name);",
263             "});",
264             "wattrs.query_tooltip_markup.connect(( mark) => {",
265             "     GLib.debug(\"tooltip query? %s\", mark.name);",
266             "    return strdup(mark.name);",
267             "});",
268             "this.el.set_mark_attributes (\"WARN\", wattrs, 1);",
269             "wattrs.ref();",
270             "",
271             " ",
272             "var dattrs = new GtkSource.MarkAttributes();",
273             " ",
274             "dattrs.set_icon_name ( \"process-stop\"); ",
275             "",
276             "dattrs.query_tooltip_text.connect(( mark) => {",
277             "\tGLib.debug(\"tooltip query? %s\", mark.name);",
278             "    return strdup(mark.name);",
279             "});",
280             "//dattrs.query_tooltip_markup.connect(( mark) => {",
281             "//\tGLib.debug(\"tooltip query? %s\", mark.name);",
282             " //   return strdup(mark.name);",
283             "//});",
284             "this.el.set_mark_attributes (\"DEPR\", dattrs, 1);",
285             "dattrs.ref();    ",
286             "",
287             " this.el.get_space_drawer().set_matrix(null);",
288             " this.el.get_space_drawer().set_types_for_locations( ",
289             "\tGtkSource.SpaceLocationFlags.ALL,",
290             "\tGtkSource.SpaceTypeFlags.ALL",
291             ");",
292             "this.el.get_space_drawer().set_enable_matrix(true);",
293             ""
294            ],
295            "* prop" : "child",
296            "bool has_tooltip" : true,
297            "bool hexpand" : true,
298            "bool insert_spaces_instead_of_tabs" : true,
299            "bool vexpand" : true,
300            "boolean show_line_marks" : true,
301            "boolean show_line_numbers" : true,
302            "css_classes" : "{ \"code-editor\" }",
303            "gboolean highlight_current_line" : true,
304            "id" : "view",
305            "indent_width" : 4,
306            "items" : [
307             {
308              "$ Gee.HashMap<int,string>? xmarks" : "null",
309              "$ xns" : "GtkSource",
310              "$ xtype" : "Buffer",
311              "* init" : [
312               "",
313               "var buf = this.el;",
314               "buf.create_tag (\"bold\", \"weight\", Pango.Weight.BOLD);",
315               "buf.create_tag (\"type\", \"weight\", Pango.Weight.BOLD, \"foreground\", \"#204a87\");",
316               "buf.create_tag (\"keyword\", \"weight\", Pango.Weight.BOLD, \"foreground\", \"#a40000\");",
317               "buf.create_tag (\"text\", \"weight\", Pango.Weight.NORMAL, \"foreground\", \"#729fcf\");",
318               "buf.create_tag (\"number\", \"weight\", Pango.Weight.BOLD, \"foreground\", \"#ad7fa8\");",
319               "buf.create_tag (\"method\", \"weight\", Pango.Weight.BOLD, \"foreground\", \"#729fcf\");",
320               "buf.create_tag (\"property\", \"weight\", Pango.Weight.BOLD, \"foreground\", \"#BC1F51\");",
321               "buf.create_tag (\"variable\", \"weight\", Pango.Weight.BOLD, \"foreground\", \"#A518B5\");",
322               "",
323               "",
324               "buf.create_tag (\"ERR\", \"weight\", Pango.Weight.BOLD, \"background\", \"pink\");",
325               "buf.create_tag (\"WARN\", \"weight\", Pango.Weight.BOLD, \"background\", \"#ABF4EB\");",
326               "buf.create_tag (\"DEPR\", \"weight\", Pango.Weight.BOLD, \"background\", \"#EEA9FF\");",
327               "",
328               "",
329               ""
330              ],
331              "* prop" : "buffer",
332              "bool check_queued" : false,
333              "bool enable_undo" : true,
334              "bool highlight_matching_brackets" : true,
335              "bool highlight_syntax" : true,
336              "id" : "buffer",
337              "int error_line" : "-1",
338              "listeners" : {
339               "changed" : [
340                " () => {",
341                "    // check syntax??",
342                "    // ??needed..??",
343                "    _this.save_button.el.sensitive = true;",
344                "    print(\"EDITOR CHANGED\");",
345                "    this.checkSyntax();",
346                "   ",
347                "    _this.dirty = true;",
348                "",
349                "    // this.get('/LeftPanel.model').changed(  str , false);",
350                "    return ;",
351                "}",
352                ""
353               ],
354               "cursor_moved" : [
355                "( ) => {",
356                "",
357                "\tGtk.TextIter iter;",
358                "\tthis.el.get_iter_at_offset (",
359                "\t\t\tout iter, this.el.cursor_position);",
360                "",
361                "\t_this.navigation.updateSelectedLine(",
362                "\t\t\t(uint)iter.get_line(),",
363                "\t\t\t(uint)iter.get_line_offset()",
364                "\t\t);",
365                "\tthis.showHelp(iter);",
366                "",
367                "}",
368                ""
369               ]
370              },
371              "| bool OLDhighlightErrorsJson" : [
372               "(string type, Json.Object obj) {",
373               "\tGtk.TextIter start;",
374               "\tGtk.TextIter end;     ",
375               "\tthis.el.get_bounds (out start, out end);",
376               "",
377               "\tthis.el.remove_source_marks (start, end, type);",
378               "\tGLib.debug(\"highlight errors\");\t\t ",
379               "",
380               "\t // we should highlight other types of errors..",
381               "",
382               "\tif (!obj.has_member(type)) {",
383               "\t\tGLib.debug(\"Return has no errors\\n\");",
384               "\t\treturn true;",
385               "\t}",
386               "",
387               "\tif (_this.window.windowstate.state != WindowState.State.CODEONLY ",
388               "\t\t&&",
389               "\t\t_this.window.windowstate.state != WindowState.State.CODE",
390               "\t\t) {",
391               "\t\tGLib.debug(\"windowstate != CODEONLY?\");",
392               "\t\t",
393               "\t\treturn true;",
394               "\t} ",
395               "",
396               "\t//this.marks = new Gee.HashMap<int,string>();",
397               "\tvar err = obj.get_object_member(type);",
398               " ",
399               "\tif (_this.file == null) {",
400               "\t\tGLib.debug(\"file is null?\");",
401               "\t\treturn true;",
402               "",
403               "\t}",
404               "\tvar valafn = _this.file.path;",
405               "",
406               "\tif (_this.file.xtype != \"PlainFile\") {",
407               "",
408               "\t\tvalafn = \"\";",
409               "\t\ttry {             ",
410               "\t\t\tvar  regex = new Regex(\"\\\\.bjs$\");",
411               "\t\t\t// should not happen",
412               "\t      \t\tvalafn = regex.replace(_this.file.path,_this.file.path.length , 0 , \".vala\");",
413               "\t\t} catch (GLib.RegexError e) {",
414               "\t\t\treturn true;",
415               "\t\t}   ",
416               "",
417               "",
418               "",
419               "\t}",
420               "\tif (!err.has_member(valafn)) {",
421               "\t\tGLib.debug(\"File path has no errors\");",
422               "\t\treturn  true;",
423               "\t}",
424               "",
425               "\tvar lines = err.get_object_member(valafn);",
426               "\t",
427               "\tvar offset = 1;",
428               "\tif (obj.has_member(\"line_offset\")) { // ?? why??",
429               "\t\toffset = (int)obj.get_int_member(\"line_offset\") + 1;",
430               "\t}",
431               "",
432               "",
433               "\tvar tlines = this.el.get_line_count () +1;",
434               "\t",
435               "\tif (_this.prop != null) {",
436               "\t",
437               "\t\ttlines = _this.prop.end_line + 1;",
438               "\t\toffset = _this.prop.start_line + 1;",
439               "\t",
440               "\t}",
441               "\t",
442               "",
443               "",
444               "\tlines.foreach_member((obj, line, node) => {",
445               "\t\t",
446               "\t     Gtk.TextIter iter;",
447               "//        print(\"get inter\\n\");",
448               "\t    var eline = int.parse(line) - offset;",
449               "\t    GLib.debug(\"GOT ERROR on line %s -- converted to %d  (offset = %d)\\n\", line,eline, offset);",
450               "\t    ",
451               "\t    ",
452               "\t    if (eline > tlines || eline < 0) {",
453               "\t        return;",
454               "\t    }",
455               "\t   ",
456               "\t    ",
457               "\t    this.el.get_iter_at_line( out iter, eline);",
458               "\t    //print(\"mark line\\n\");",
459               "\t    var msg  = \"\";",
460               "\t    var ar = lines.get_array_member(line);",
461               "\t    for (var i = 0 ; i < ar.get_length(); i++) {",
462               "\t    \tif (ar.get_string_element(i) == \"Success\") {",
463               "\t    \t\tcontinue;",
464               "    \t\t}",
465               "\t\t\tmsg += (msg.length > 0) ? \"\\n\" : \"\";",
466               "\t\t\tmsg += ar.get_string_element(i);",
467               "\t\t}",
468               "\t\tif (msg == \"\") {",
469               "\t\t\treturn;",
470               "\t\t}",
471               "\t\tmsg = \"Line: %d\".printf(eline+1) +  \" \" + msg;",
472               "\t    this.el.create_source_mark(msg, type, iter);",
473               "\t    GLib.debug(\"set line %d to %m\", eline, msg);",
474               "\t   // this.marks.set(eline, msg);",
475               "\t} );",
476               "\treturn false;",
477               "",
478               "",
479               "",
480               "",
481               "",
482               "\t}",
483               ""
484              ],
485              "| bool checkSyntax" : [
486               " () {",
487               " ",
488               "    ",
489               "    var str = this.toString();",
490               "    ",
491               "    // needed???",
492               "    if (this.error_line > 0) {",
493               "         Gtk.TextIter start;",
494               "         Gtk.TextIter end;     ",
495               "        this.el.get_bounds (out start, out end);",
496               "",
497               "        this.el.remove_source_marks (start, end, null);",
498               "    }",
499               "    if (str.length < 1) {",
500               "        print(\"checkSyntax - empty string?\\n\");",
501               "        return true;",
502               "    }",
503               "    ",
504               "    // bit presumptiona",
505               "    if (_this.file.xtype == \"PlainFile\") {",
506               "    ",
507               "        // assume it's gtk...",
508               "         var  oldcode =_this.file.toSource();",
509               "        _this.file.setSource(str);",
510               "\t    BuilderApplication.showSpinner(\"appointment soon\",\"document change pending\");",
511               "    \t_this.file.getLanguageServer().document_change(_this.file);",
512               "\t\t_this.file.getLanguageServer().queueDocumentSymbols(_this.file);",
513               "        _this.file.setSource(oldcode);",
514               "        ",
515               "\t\t ",
516               "        return true;",
517               "    ",
518               "    }",
519               "   if (_this.file == null) {",
520               "       return true;",
521               "   }",
522               " ",
523               "    ",
524               "",
525               "      ",
526               "     ",
527               "    GLib.debug(\"calling validate\");    ",
528               "    // clear the buttons.",
529               " \tif (_this.prop.name == \"xns\" || _this.prop.name == \"xtype\") {",
530               "\t\treturn true ;",
531               "\t}",
532               "\tvar oldcode  = _this.prop.val;",
533               "\t",
534               "\t_this.prop.val = str;",
535               "\t_this.node.updated_count++;",
536               "    _this.file.getLanguageServer().document_change(_this.file);",
537               "    _this.node.updated_count++;",
538               "    _this.prop.val = oldcode;",
539               "    ",
540               "    ",
541               "    //print(\"done mark line\\n\");",
542               "     ",
543               "    return true; // at present allow saving - even if it's invalid..",
544               "}",
545               ""
546              ],
547              "| bool highlightErrors" : [
548               "( Gee.HashMap<int,string> validate_res) {",
549               "         ",
550               "\tthis.error_line = validate_res.size;",
551               "",
552               "\tif (this.error_line < 1) {",
553               "\t\treturn true;",
554               "\t}",
555               "\tvar tlines = this.el.get_line_count ();",
556               "\tGtk.TextIter iter;",
557               "\tvar valiter = validate_res.map_iterator();",
558               "\twhile (valiter.next()) {",
559               "",
560               "\t//        print(\"get inter\\n\");",
561               "\t\tvar eline = valiter.get_key();",
562               "\t\tif (eline > tlines) {",
563               "\t\t\tcontinue;",
564               "\t\t}",
565               "\t\tthis.el.get_iter_at_line( out iter, eline);",
566               "\t\t//print(\"mark line\\n\");",
567               "\t\tthis.el.create_source_mark(valiter.get_value(), \"ERR\", iter);",
568               "\t}   ",
569               "\treturn false;",
570               "}"
571              ],
572              "| string toString" : [
573               "  () {",
574               "    ",
575               "    Gtk.TextIter s;",
576               "    Gtk.TextIter e;",
577               "    this.el.get_start_iter(out s);",
578               "    this.el.get_end_iter(out e);",
579               "    var ret = this.el.get_text(s,e,true);",
580               "    //print(\"TO STRING? \" + ret);",
581               "    return ret;",
582               "}",
583               " "
584              ],
585              "| void showHelp" : [
586               "(Gtk.TextIter iter) {",
587               "\tvar back = iter.copy();",
588               "\tback.backward_char();",
589               "\t",
590               "\tvar forward = iter.copy();",
591               "\tforward.forward_char();",
592               "\t",
593               "\t// what's the character at the iter?",
594               "\tvar str = back.get_text(iter);",
595               "\tstr += iter.get_text(forward);",
596               "\tif (str.strip().length < 1) {",
597               "\t\treturn;",
598               "\t}",
599               "\tvar offset = iter.get_line_offset();",
600               "\tvar line = iter.get_line();",
601               "\tif (_this.prop != null) {",
602               "\t\t\t\t// ",
603               "\t\tline += _this.prop.start_line ; ",
604               "\t\t\t\t\t// this is based on Gtk using tabs (hence 1/2 chars);",
605               "\t\toffset += _this.node.node_pad.length;",
606               "\t\t\t\t\t// javascript listeners are indented 2 more spaces.",
607               "\t\tif (_this.prop.ptype == JsRender.NodePropType.LISTENER) {",
608               "\t\t\toffset += 2;",
609               "\t\t}",
610               "\t} ",
611               "\t",
612               "\tvar ls = _this.file.getLanguageServer();",
613               "\tls.hover.begin(",
614               "\t\t_this.file, line, offset,",
615               "\t\t( a, o)  => {",
616               "\t\t\ttry {",
617               "\t\t\t\tvar res = ls.hover.end(o );",
618               "\t\t\t",
619               "\t\t\t\t_this.helper.setHelp(res);",
620               "\t\t\t} catch (GLib.Error e) {",
621               "\t\t\t\t// noop..",
622               "\t\t\t}",
623               "\t\t});",
624               "}\t",
625               "\t\t ",
626               ""
627              ]
628             },
629             {
630              "# bool is_control" : false,
631              "$ xns" : "Gtk",
632              "id" : "keystate",
633              "listeners" : {
634               "key_pressed" : [
635                "(keyval, keycode, state) => {",
636                "",
637                " \tif (keyval == Gdk.Key.Control_L || keyval == Gdk.Key.Control_R) {",
638                " \t\tthis.is_control = true;",
639                "\t}",
640                "\treturn false;",
641                "}",
642                ""
643               ],
644               "key_released" : [
645                "(keyval, keycode, state) => {",
646                "",
647                " \t if (keyval == Gdk.Key.Control_L || keyval == Gdk.Key.Control_R) {",
648                " \t\tthis.is_control = false;",
649                "\t}",
650                "    if (keyval == Gdk.Key.s && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {",
651                "        GLib.debug(\"SAVE: ctrl-S  pressed\");",
652                "        _this.saveContents();",
653                "        return;",
654                "    }",
655                "    ",
656                "    if (keyval == Gdk.Key.g && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {",
657                "\t    GLib.debug(\"SAVE: ctrl-g  pressed\");",
658                "\t\t_this.forwardSearch(true);",
659                "\t    return;",
660                "\t}",
661                "\tif (keyval == Gdk.Key.f && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {",
662                "\t    GLib.debug(\"SAVE: ctrl-f  pressed\");",
663                "\t\t_this.search_entry.el.grab_focus();",
664                "\t\t_this.search_entry.el.select_region(0,-1);",
665                "\t    return;",
666                "\t}",
667                "\tif (keyval == Gdk.Key.space && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {",
668                "\t\t_this.view.el.show_completion();",
669                "\t}",
670                "\t",
671                "\tGtk.TextIter iter;",
672                "\t_this.buffer.el.get_iter_at_offset( out iter, _this.buffer.el.cursor_position);  ",
673                "\tvar line  = iter.get_line();",
674                "\tvar offset = iter.get_line_offset();",
675                "\tGLib.debug(\"line  %d  off %d\", line ,offset);",
676                "\tif (_this.prop != null) {",
677                "\t\tline += _this.prop.start_line + 1; // i think..",
678                "\t\toffset += 12; // should probably be 8 without namespaced ",
679                "\t\tGLib.debug(\"guess line  %d  off %d\", line ,offset);",
680                "\t} ",
681                "    //_this.view.el.show_completion();",
682                "   // print(event.key.keyval)",
683                "    ",
684                "    ",
685                "    return;",
686                " ",
687                " ",
688                "}",
689                ""
690               ]
691              },
692              "xtype" : "EventControllerKey"
693             },
694             {
695              "# double distance" : "0.0f",
696              "$ xns" : "Gtk",
697              "Gtk.EventControllerScrollFlags flags" : "Gtk.EventControllerScrollFlags.VERTICAL",
698              "listeners" : {
699               "scroll" : [
700                "(dx, dy) => {",
701                "\tif (!_this.keystate.is_control) {",
702                "\t\treturn false;",
703                "\t}",
704                "\t //GLib.debug(\"scroll %f\",  dy);",
705                "\t",
706                "\tthis.distance += dy;",
707                "\t",
708                "\t//GLib.debug(\"scroll %f / %f\",  dy, this.distance);",
709                " ",
710                "\t if (this.distance < -1) {",
711                " ",
712                "\t\tBuilderApplication.settings.editor_font_size ++;",
713                "\t\tthis.distance = 0;",
714                "\t}",
715                "\tif (this.distance > 1) {",
716                "\t\tBuilderApplication.settings.editor_font_size --;",
717                "\t\tthis.distance = 0;",
718                "\t}",
719                "\t ",
720                "\treturn true;",
721                "}",
722                ""
723               ]
724              },
725              "xtype" : "EventControllerScroll"
726             },
727             {
728              "$ xns" : "Gtk",
729              "listeners" : {
730               "pressed" : [
731                "(n_press, x, y) => {",
732                "\tGtk.TextIter iter;",
733                "\tint  buffer_x, buffer_y;",
734                "\tvar gut = _this.view.el.get_gutter(Gtk.TextWindowType.LEFT);",
735                "\t",
736                "\t _this.view.el.window_to_buffer_coords (Gtk.TextWindowType.TEXT,",
737                "\t\t(int)x - gut.get_width(),  (int)y,",
738                "  \t\tout  buffer_x, out  buffer_y);",
739                "\t_this.view.el.get_iter_at_location (out  iter,  ",
740                "\t\t\tbuffer_x,  buffer_y);;",
741                "\t",
742                "\t",
743                "\tif (_this.buffer.el.iter_has_context_class(iter, \"comment\") ||",
744                "\t\t_this.buffer.el.iter_has_context_class(iter, \"string\")",
745                "\t) { ",
746                "\t\treturn ;",
747                "\t}",
748                "\t_this.buffer.showHelp(iter);",
749                "\t ",
750                "\t\t ",
751                " ",
752                "}",
753                ""
754               ]
755              },
756              "xtype" : "GestureClick"
757             }
758            ],
759            "listeners" : {
760             "query_tooltip" : [
761              "(x, y, keyboard_tooltip, tooltip) => {",
762              "\t",
763              "\t//GLib.debug(\"query tooltip\");",
764              "\tGtk.TextIter iter;",
765              "\tint trailing;",
766              "\t",
767              "\tvar yoff = (int) _this.RightEditor.el.vadjustment.value;",
768              "\t",
769              "\t// I think this is problematic - if it's compliing  / updating at same time as query.",
770              "\t",
771              "\t//if (_this.window.statusbar_compile_spinner.el.spinning) {",
772              "\t//\treturn false;",
773              "\t//}",
774              "\t",
775              "\tthis.el.get_iter_at_position (out iter, out trailing,  x,  y + yoff);",
776              "\t ",
777              "\tvar l = iter.get_line();",
778              "",
779              "\t",
780              "\t ",
781              "\t// GLib.debug(\"query tooltip line %d\", (int) l);",
782              "\tif (l < 0) {",
783              "",
784              "\t\treturn false;",
785              "\t}",
786              "\t/*",
787              "\tif (_this.buffer.marks != null && _this.buffer.marks.has_key(l)) {",
788              "\t\tGLib.debug(\"line %d setting tip to %s\", l,  _this.buffer.marks.get(l));",
789              "\t\ttooltip.set_text(_this.buffer.marks.get(l).dup());",
790              "\t\treturn true;",
791              "\t}",
792              " ",
793              "\treturn false;",
794              "\t*/",
795              "\t",
796              "\t  ",
797              "\t// this crashes?? - not sure why.",
798              "\tvar marks = _this.buffer.el.get_source_marks_at_line(l, \"ERR\");",
799              "\tif (marks.is_empty()) {",
800              "\t\tmarks = _this.buffer.el.get_source_marks_at_line(l, \"WARN\");",
801              "\t}",
802              "\tif (marks.is_empty()) {",
803              "\t\tmarks = _this.buffer.el.get_source_marks_at_line(l, \"DEPR\");",
804              "\t}",
805              "\t",
806              "\t// GLib.debug(\"query tooltip line %d marks %d\", (int)l, (int) marks.length());",
807              "\tvar str = \"\";",
808              "\tmarks.@foreach((m) => { ",
809              "\t\t//GLib.debug(\"got mark %s\", m.name);",
810              "\t\tstr += (str.length > 0 ? \"\\n\" : \"\") + m.category + \": \" + m.name;",
811              "\t});",
812              "\t// true if there is a mark..",
813              "\tif (str.length > 0 ) {",
814              "\t\ttooltip.set_text( str );",
815              "\t}",
816              "\treturn str.length > 0 ? true : false;",
817              "\t ",
818              "}",
819              ""
820             ]
821            },
822            "string name" : "editor-view",
823            "uint tab_width" : 4,
824            "xtype" : "View",
825            "| void load" : [
826             " (string str) {",
827             "",
828             "// show the help page for the active node..",
829             "   //this.get('/Help').show();",
830             " ",
831             "  // this.get('/BottomPane').el.set_current_page(0);",
832             "  \tGLib.debug(\"load called - Reset undo buffer\");",
833             "  \t",
834             "    var buf = (GtkSource.Buffer)this.el.get_buffer();",
835             "    buf.begin_irreversible_action();",
836             "    buf.set_text(str, str.length);",
837             "    buf.end_irreversible_action();",
838             "    ",
839             "    var lm = GtkSource.LanguageManager.get_default();",
840             "    var lang = \"vala\";",
841             "    if (_this.file != null) {",
842             "         lang = _this.file.language;",
843             "    }",
844             "    print(\"lang=%s, content_type = %s\\n\", lang, _this.file.content_type);",
845             "    var lg = _this.file.content_type.length > 0  ?",
846             "            lm.guess_language(_this.file.path, _this.file.content_type) :",
847             "            lm.get_language(lang);",
848             "     ",
849             "   ",
850             "    ((GtkSource.Buffer)(this.el.get_buffer())) .set_language(lg); ",
851             "",
852             "    this.el.insert_spaces_instead_of_tabs = true;",
853             "    if (lg != null) {",
854             "\t\tprint(\"sourcelanguage  = %s\\n\", lg.name);",
855             "\t\tif (lg.name == \"Vala\") {",
856             "\t\t    this.el.insert_spaces_instead_of_tabs = false;",
857             "\t\t}",
858             "     }",
859             "    _this.dirty = false;",
860             "    this.el.grab_focus();",
861             "    _this.save_button.el.sensitive = false;",
862             "    _this.last_error_counter = -1;",
863             "}"
864            ]
865           }
866          ],
867          "xtype" : "ScrolledWindow"
868         },
869         {
870          "$ xns" : "Gtk",
871          "* pack" : "append",
872          "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
873          "bool homogeneous" : false,
874          "bool vexpand" : false,
875          "int spacing" : 0,
876          "items" : [
877           {
878            "$ xns" : "Gtk",
879            "Gtk.CssProvider css" : "",
880            "bool hexpand" : true,
881            "id" : "search_entry",
882            "items" : [
883             {
884              "$ xns" : "Gtk",
885              "listeners" : {
886               "key_pressed" : [
887                "(keyval, keycode, state) => {",
888                "",
889                "\tif (keyval == Gdk.Key.g && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {",
890                "\t    GLib.debug(\"SAVE: ctrl-g  pressed\");",
891                "\t\t_this.forwardSearch(true);",
892                "\t    return true;",
893                "\t}",
894                "    ",
895                "  ",
896                " \tif (keyval == Gdk.Key.Return && _this.search_entry.el.text.length > 0) {",
897                "\t\t_this.forwardSearch(true);",
898                "\t\t",
899                "\t\t",
900                "\t    return true;",
901                "",
902                "\t}    ",
903                "   // print(event.key.keyval)",
904                "   ",
905                "    return false;",
906                "}",
907                ""
908               ]
909              },
910              "xtype" : "EventControllerKey"
911             }
912            ],
913            "listeners" : {
914             "search_changed" : [
915              "( ) => {",
916              "",
917              "_this.search(_this.search_entry.el.text);",
918              "\t _this.search_results.updateResults();",
919              "",
920              "\tGLib.Timeout.add_seconds(1,() => {",
921              "\t\t _this.search_results.updateResults();",
922              "\t\t return false;",
923              "\t });",
924              "}",
925              ""
926             ]
927            },
928            "string name" : "editor-search-entry",
929            "string placeholder_text" : "Press enter to search",
930            "uint search_delay" : 3,
931            "xtype" : "SearchEntry",
932            "| void forwardSearch" : [
933             "(bool change_focus) {",
934             "",
935             "",
936             "\t_this.forwardSearch(change_focus);",
937             "",
938             "/*",
939             "",
940             "\tswitch(_this.windowstate.state) {",
941             "\t\tcase WindowState.State.CODEONLY:",
942             "\t\t//case WindowState.State.CODE:",
943             "\t\t\t// search the code being edited..",
944             "\t\t\t_this.windowstate.code_editor_tab.forwardSearch(change_focus);",
945             "\t\t\t ",
946             "\t\t\tbreak;",
947             "\t\tcase WindowState.State.PREVIEW:",
948             "\t\t\tif (_this.windowstate.file.xtype == \"Gtk\") {",
949             "\t\t\t\t_this.windowstate.window_gladeview.forwardSearch(change_focus);",
950             "\t\t\t} else { ",
951             "\t\t\t\t _this.windowstate.window_rooview.forwardSearch(change_focus);",
952             "\t\t\t}",
953             "\t\t",
954             "\t\t\tbreak;",
955             "\t}",
956             "\t*/",
957             "\t",
958             "}",
959             ""
960            ]
961           },
962           {
963            "$ xns" : "Gtk",
964            "id" : "search_results",
965            "int margin_end" : 4,
966            "int margin_start" : 4,
967            "string label" : "No Results",
968            "xtype" : "Label",
969            "| void updateResults" : [
970             "() {",
971             "\tthis.el.visible = true;",
972             "\t",
973             "\tvar res = _this.searchcontext.get_occurrences_count();",
974             "\tif (res < 0) {",
975             "\t\t_this.search_results.el.label = \"??? Matches\";\t\t",
976             "\t\treturn;",
977             "\t}",
978             "",
979             "\t_this.nextBtn.el.sensitive = false;",
980             "\t_this.backBtn.el.sensitive = false;\t",
981             "",
982             "\tif (res > 0) {",
983             "\t\t_this.search_results.el.label = \"%d Matches\".printf(res);",
984             "\t\t_this.nextBtn.el.sensitive = true;",
985             "\t\t_this.backBtn.el.sensitive = true;",
986             "\t\treturn;",
987             "\t} ",
988             "\t_this.search_results.el.label = \"No Matches\";",
989             "\t",
990             "}"
991            ]
992           },
993           {
994            "$ xns" : "Gtk",
995            "bool always_show_image" : true,
996            "bool sensitive" : false,
997            "id" : "nextBtn",
998            "listeners" : {
999             "clicked" : [
1000              "(event) => {",
1001              "",
1002              "\t_this.forwardSearch(true);",
1003              "\t",
1004              "\t ",
1005              "}",
1006              ""
1007             ]
1008            },
1009            "string icon_name" : "go-down",
1010            "xtype" : "Button"
1011           },
1012           {
1013            "$ xns" : "Gtk",
1014            "bool always_show_image" : true,
1015            "bool sensitive" : false,
1016            "id" : "backBtn",
1017            "listeners" : {
1018             "clicked" : [
1019              "(event) => {",
1020              "",
1021              "\t_this.backSearch(true);",
1022              "\t ",
1023              "}",
1024              ""
1025             ]
1026            },
1027            "string icon_name" : "go-up",
1028            "xtype" : "Button"
1029           },
1030           {
1031            "$ xns" : "Gtk",
1032            "bool always_show_arrow" : true,
1033            "bool always_show_image" : true,
1034            "items" : [
1035             {
1036              "$ xns" : "Gtk",
1037              "* prop" : "popover",
1038              "id" : "search_settings",
1039              "items" : [
1040               {
1041                "$ xns" : "Gtk",
1042                "* prop" : "child",
1043                "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
1044                "int spacing" : 0,
1045                "items" : [
1046                 {
1047                  "$ xns" : "Gtk",
1048                  "* init" : [
1049                   "{",
1050                   "\tthis.el.show();",
1051                   "}",
1052                   ""
1053                  ],
1054                  "id" : "case_sensitive",
1055                  "string label" : "Case Sensitive",
1056                  "xtype" : "CheckButton"
1057                 },
1058                 {
1059                  "$ xns" : "Gtk",
1060                  "* init" : [
1061                   "{",
1062                   "\tthis.el.show();",
1063                   "}",
1064                   ""
1065                  ],
1066                  "id" : "regex",
1067                  "string label" : "Regex",
1068                  "xtype" : "CheckButton"
1069                 },
1070                 {
1071                  "$ xns" : "Gtk",
1072                  "id" : "multiline",
1073                  "string label" : "Multi-line (add \\n)",
1074                  "xtype" : "CheckButton"
1075                 }
1076                ],
1077                "xtype" : "Box"
1078               }
1079              ],
1080              "xtype" : "Popover"
1081             }
1082            ],
1083            "string icon_name" : "emblem-system",
1084            "xtype" : "MenuButton"
1085           }
1086          ],
1087          "xtype" : "Box"
1088         }
1089        ],
1090        "xtype" : "Box"
1091       },
1092       {
1093        "$ xns" : "Gtk",
1094        "* prop" : "end_child",
1095        "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
1096        "bool hexpand" : true,
1097        "bool vexpand" : true,
1098        "bool visible" : false,
1099        "id" : "navigation_holder",
1100        "int spacing" : 0,
1101        "int width_request" : 120,
1102        "items" : [
1103         {
1104          "$ xns" : "Gtk",
1105          "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
1106          "int spacing" : 0,
1107          "xtype" : "Box"
1108         },
1109         {
1110          "$ xns" : "Gtk",
1111          "bool hexpand" : true,
1112          "bool vexpand" : true,
1113          "bool visible" : true,
1114          "id" : "navigationwindow",
1115          "items" : [
1116           {
1117            "# int last_selected_line" : "-1",
1118            "$ Gtk.Widget? selected_row" : "null",
1119            "$ xns" : "Gtk",
1120            "* prop" : "child",
1121            "id" : "navigation",
1122            "items" : [
1123             {
1124              "$ xns" : "Gtk",
1125              "bool expand" : true,
1126              "items" : [
1127               {
1128                "$ xns" : "Gtk",
1129                "* prop" : "factory",
1130                "listeners" : {
1131                 "bind" : [
1132                  "(listitem) => {",
1133                  "\t ",
1134                  "\t// GLib.debug(\"listitme is is %s\", ((Gtk.ListItem)listitem).get_type().name());",
1135                  "\t",
1136                  "\t//var expand = (Gtk.TreeExpander) ((Gtk.ListItem)listitem).get_child();",
1137                  "\tvar expand = (Gtk.TreeExpander)  ((Gtk.ListItem)listitem).get_child();",
1138                  "\t ",
1139                  "\t ",
1140                  "\tvar hbox = (Gtk.Box) expand.child;",
1141                  " ",
1142                  "\t",
1143                  "\tvar img = (Gtk.Image) hbox.get_first_child();",
1144                  "\tvar lbl = (Gtk.Label) img.get_next_sibling();",
1145                  "\t",
1146                  "\tvar lr = (Gtk.TreeListRow)((Gtk.ListItem)listitem).get_item();",
1147                  "\tvar sym = (Lsp.DocumentSymbol) lr.get_item();",
1148                  "\t",
1149                  "\tsym.set_data<Gtk.Widget>(\"widget\", expand.get_parent());",
1150                  "\texpand.get_parent().get_parent().set_data<Lsp.DocumentSymbol>(\"symbol\", sym);",
1151                  "\t",
1152                  "\t//GLib.debug(\"save sym on %s\", expand.get_parent().get_parent().get_type().name());",
1153                  "\t",
1154                  "\t//GLib.debug(\"got %d children for %s\" , (int)sym.children.get_n_items(), sym.name);",
1155                  "    ",
1156                  "    expand.set_hide_expander( sym.children.get_n_items()  < 1);",
1157                  " \texpand.set_list_row(lr);",
1158                  " \t//this.in_bind = true;",
1159                  " \t// default is to expand",
1160                  " ",
1161                  " \t//this.in_bind = false;",
1162                  " \t",
1163                  " \tsym.bind_property(\"symbol_icon\",",
1164                  "                    img, \"icon_name\",",
1165                  "                   GLib.BindingFlags.SYNC_CREATE);",
1166                  " \t",
1167                  " \thbox.css_classes = { sym.symbol_icon };",
1168                  " \t",
1169                  " \tsym.bind_property(\"name\",",
1170                  "                    lbl, \"label\",",
1171                  "                   GLib.BindingFlags.SYNC_CREATE);",
1172                  " \t// should be better?- --line no?",
1173                  " \tsym.bind_property(\"tooltip\",",
1174                  "                    lbl, \"tooltip_markup\",",
1175                  "                   GLib.BindingFlags.SYNC_CREATE);",
1176                  " \t// bind image...",
1177                  " \t",
1178                  "}",
1179                  ""
1180                 ],
1181                 "setup" : [
1182                  "(listitem) => {",
1183                  "\t",
1184                  "\tvar expand = new Gtk.TreeExpander();",
1185                  "\t ",
1186                  "\texpand.set_indent_for_depth(true);",
1187                  "\texpand.set_indent_for_icon(true);",
1188                  "\tvar hbox = new Gtk.Box(Gtk.Orientation.HORIZONTAL,0);",
1189                  "\tvar icon = new Gtk.Image();",
1190                  "\tvar lbl = new Gtk.Label(\"\");",
1191                  "\tlbl.use_markup = true;",
1192                  "\tlbl.ellipsize = Pango.EllipsizeMode.END;",
1193                  "\t",
1194                  "\ticon.margin_end = 4;",
1195                  " \tlbl.justify = Gtk.Justification.LEFT;",
1196                  " \tlbl.xalign = 0;",
1197                  "",
1198                  "//\tlistitem.activatable = true; ??",
1199                  "\t",
1200                  "\thbox.append(icon);",
1201                  "\thbox.append(lbl);",
1202                  "\texpand.set_child(hbox);",
1203                  "\t((Gtk.ListItem)listitem).set_child(expand);",
1204                  "\t",
1205                  "}",
1206                  ""
1207                 ]
1208                },
1209                "xtype" : "SignalListItemFactory"
1210               }
1211              ],
1212              "string title" : "Code Navigation",
1213              "xtype" : "ColumnViewColumn"
1214             },
1215             {
1216              "$ xns" : "Gtk",
1217              "* prop" : "model",
1218              "id" : "navigationselmodel",
1219              "items" : [
1220               {
1221                "$ xns" : "Gtk",
1222                "* prop" : "model",
1223                "id" : "navigationsort",
1224                "items" : [
1225                 {
1226                  "$ Gtk.TreeListModelCreateModelFunc create_func" : [
1227                   "(item) => {",
1228                   " ",
1229                   "\treturn ((Lsp.DocumentSymbol)item).children;",
1230                   "}",
1231                   ""
1232                  ],
1233                  "$ xns" : "Gtk",
1234                  "* prop" : "model",
1235                  "bool autoexpand" : true,
1236                  "bool passthrough" : false,
1237                  "items" : [
1238                   {
1239                    "$ GLib.Type item_type" : "typeof(Lsp.DocumentSymbol)",
1240                    "$ xns" : "GLib",
1241                    "* prop" : "root",
1242                    "id" : "navliststore",
1243                    "xtype" : "ListStore",
1244                    "| Lsp.DocumentSymbol? symbolAtLine" : [
1245                     "(uint line, uint chr) {",
1246                     " ",
1247                     "\t",
1248                     "\tfor(var i = 0; i < this.el.get_n_items();i++) {",
1249                     "\t\tvar el = (Lsp.DocumentSymbol)this.el.get_item(i);",
1250                     "\t\t//GLib.debug(\"Check sym %s : %d-%d\",",
1251                     "\t\t//\tel.name , (int)el.range.start.line,",
1252                     "\t\t//\t(int)el.range.end.line",
1253                     "\t\t//);",
1254                     "\t\tvar ret = el.containsLine(line,chr);",
1255                     "\t\tif (ret != null) {",
1256                     "\t\t\treturn ret;",
1257                     "\t\t}",
1258                     "\t\t",
1259                     "\t}",
1260                     "\t",
1261                     "\treturn null;",
1262                     "}"
1263                    ]
1264                   }
1265                  ],
1266                  "listeners" : {
1267                   "items_changed" : [
1268                    "(position, removed, added) => {",
1269                    "\tGLib.debug(\"tree item changed %d , %d , %d\",(int) position, (int)removed, (int) added);",
1270                    "\t if (added < 1) { ",
1271                    "\t \treturn;",
1272                    " \t}",
1273                    "\t//var sym = (Lsp.DocumentSymbol) this.el.get_item(position);",
1274                    "\tvar row = this.el.get_row(position);",
1275                    "\t",
1276                    "\tGLib.debug(\"got %s\", row.get_item().get_type().name());",
1277                    "\t",
1278                    "",
1279                    "}",
1280                    ""
1281                   ]
1282                  },
1283                  "xtype" : "TreeListModel"
1284                 },
1285                 {
1286                  "$ xns" : "Gtk",
1287                  "* prop" : "sorter",
1288                  "items" : [
1289                   {
1290                    "$ xns" : "Gtk",
1291                    "* prop" : "sorter",
1292                    "items" : [
1293                     {
1294                      "$ GLib.Type this_type" : "typeof(Lsp.DocumentSymbol)",
1295                      "$ xns" : "Gtk",
1296                      "* prop" : "expression",
1297                      "string property_name" : "sort_key",
1298                      "xtype" : "PropertyExpression"
1299                     }
1300                    ],
1301                    "xtype" : "StringSorter"
1302                   }
1303                  ],
1304                  "xtype" : "TreeListRowSorter"
1305                 }
1306                ],
1307                "xtype" : "SortListModel",
1308                "| Lsp.DocumentSymbol? getSymbolAt" : [
1309                 "(uint row) {",
1310                 "",
1311                 "   var tr = (Gtk.TreeListRow)this.el.get_item(row);",
1312                 "   ",
1313                 "   var a = tr.get_item();;   ",
1314                 "   GLib.debug(\"get_item (2) = %s\", a.get_type().name());",
1315                 "  \t",
1316                 "   ",
1317                 "   return (Lsp.DocumentSymbol)tr.get_item();",
1318                 "\t ",
1319                 "}"
1320                ],
1321                "| int getRowFromSymbol" : [
1322                 "(Lsp.DocumentSymbol sym) {",
1323                 "",
1324                 "\tfor (var i=0;i < this.el.get_n_items(); i++) {",
1325                 "\t\tvar tr = (Gtk.TreeListRow)this.el.get_item(i);",
1326                 "\t   ",
1327                 "\t\tif (sym.equals( (Lsp.DocumentSymbol)tr.get_item())) {",
1328                 "\t\t\treturn i;",
1329                 "\t\t}",
1330                 "\t}",
1331                 "   \treturn -1;",
1332                 "}"
1333                ],
1334                "| void collapseOnLoad" : [
1335                 "() {",
1336                 "\tfor (var i=0;i < this.el.get_n_items(); i++) {",
1337                 "\t\tvar tr = (Gtk.TreeListRow)this.el.get_item(i);",
1338                 "\t\tvar sym =  (Lsp.DocumentSymbol)tr.get_item();",
1339                 "\t\tswitch (sym.kind) {",
1340                 "\t \t\tcase Lsp.SymbolKind.Enum: ",
1341                 "\t \t\t\ttr.expanded = false;",
1342                 "\t \t\t\tbreak;",
1343                 "\t\t\tdefault:",
1344                 "\t\t\t\t//tr.expanded = true;",
1345                 "\t\t\t\tbreak;",
1346                 "\t\t}",
1347                 "\t}",
1348                 " ",
1349                 "\t",
1350                 "",
1351                 "",
1352                 "}"
1353                ]
1354               }
1355              ],
1356              "xtype" : "NoSelection"
1357             },
1358             {
1359              "$ xns" : "Gtk",
1360              "listeners" : {
1361               "pressed" : [
1362                "(n_press, x, y) => {",
1363                "\tstring pos;",
1364                "  \tvar row = _this.navigation.getRowWidgetAt(x,y, out pos );",
1365                "",
1366                "    if (row == null) {",
1367                "\t    GLib.debug(\"no row selected items\");",
1368                "\t    return;",
1369                "    }",
1370                "\tGLib.debug(\"got click on %s\", row.get_type().name());    ",
1371                "    //Lsp.DocumentSymbol",
1372                "    var sym =  row.get_data<Lsp.DocumentSymbol>(\"symbol\");",
1373                "    if (sym == null) {",
1374                "    \treturn;",
1375                "\t}",
1376                "\t/*",
1377                "\t \"range\" : {",
1378                "              \"start\" : {",
1379                "                \"line\" : 1410,",
1380                "                \"character\" : 8",
1381                "              },",
1382                "              \"end\" : {",
1383                "                \"line\" : 1410,",
1384                "                \"character\" : 39",
1385                "              }",
1386                "            },",
1387                "        */",
1388                "     GLib.debug(\"goto line %d\",   (int)sym.range.start.line); ",
1389                "    _this.scroll_to_line((int)sym.range.start.line);",
1390                "    Gtk.TextIter iter;",
1391                "    _this.buffer.el.get_iter_at_line_offset(out iter, ",
1392                "    \t(int)sym.range.start.line,",
1393                "    \t(int)sym.range.start.character",
1394                "\t);",
1395                "    _this.buffer.el.place_cursor(iter);",
1396                "\t",
1397                "}"
1398               ]
1399              },
1400              "xtype" : "GestureClick"
1401             }
1402            ],
1403            "string name" : "editor-navigation",
1404            "xtype" : "ColumnView",
1405            "| Gtk.Widget? getRowWidgetAt" : [
1406             "(double x,  double  y, out string pos) {",
1407             "",
1408             "\tpos = \"\";",
1409             "\tvar w = this.el.pick(x, y, Gtk.PickFlags.DEFAULT);",
1410             "\t//GLib.debug(\"got widget %s\", w == null ? \"nothing\" : w.get_type().name());",
1411             "\tif (w == null) {",
1412             "\t\treturn null;",
1413             "\t}",
1414             "\t",
1415             "\tvar row= w.get_ancestor(GLib.Type.from_name(\"GtkColumnViewRowWidget\"));",
1416             "\tif (row == null) {",
1417             "\t\treturn null;",
1418             "\t}",
1419             "\t",
1420             "\t//GLib.debug(\"got colview %s\", row == null ? \"nothing\" : row.get_type().name());",
1421             "\t ",
1422             " ",
1423             "\t",
1424             "\t//GLib.debug(\"row number is %d\", rn);",
1425             "\t//GLib.debug(\"click %d, %d\", (int)x, (int)y);",
1426             "\t// above or belw",
1427             "\tGraphene.Rect  bounds;",
1428             "\trow.compute_bounds(this.el, out bounds);",
1429             "\t//GLib.debug(\"click x=%d, y=%d, w=%d, h=%d\", ",
1430             "\t//\t(int)bounds.get_x(), (int)bounds.get_y(),",
1431             "\t//\t(int)bounds.get_width(), (int)bounds.get_height()",
1432             "\t//\t);",
1433             "\tvar ypos = y - bounds.get_y();",
1434             "\t//GLib.debug(\"rel ypos = %d\", (int)ypos);\t",
1435             "\tvar rpos = 100.0 * (ypos / bounds.get_height());",
1436             "\t//GLib.debug(\"rel pos = %d %%\", (int)rpos);",
1437             "\tpos = \"over\";",
1438             "\t",
1439             "\tif (rpos > 80) {",
1440             "\t\tpos = \"below\";",
1441             "\t} else if (rpos < 20) {",
1442             "\t\tpos = \"above\";",
1443             "\t} ",
1444             "\treturn row;",
1445             " }"
1446            ],
1447            "| int getRowAt" : [
1448             "(double x,  double  y, out string pos) {",
1449             "",
1450             "\tpos = \"\";",
1451             "\tvar w = this.el.pick(x, y, Gtk.PickFlags.DEFAULT);",
1452             "\t//GLib.debug(\"got widget %s\", w == null ? \"nothing\" : w.get_type().name());",
1453             "\tif (w == null) {",
1454             "\t\treturn -1;",
1455             "\t}",
1456             "\t",
1457             "\tvar row= w.get_ancestor(GLib.Type.from_name(\"GtkColumnViewRowWidget\"));",
1458             "\tif (row == null) {",
1459             "\t\treturn -1;",
1460             "\t}",
1461             "\t",
1462             "\t//GLib.debug(\"got colview %s\", row == null ? \"nothing\" : row.get_type().name());",
1463             "\t ",
1464             "\tvar rn = 0;",
1465             "\tvar cr = row;",
1466             "\t ",
1467             "\twhile (cr.get_prev_sibling() != null) {",
1468             "\t\trn++;",
1469             "\t\tcr = cr.get_prev_sibling();",
1470             "\t}",
1471             "\t",
1472             "\t//GLib.debug(\"row number is %d\", rn);",
1473             "\t//GLib.debug(\"click %d, %d\", (int)x, (int)y);",
1474             "\t// above or belw",
1475             "\tGraphene.Rect  bounds;",
1476             "\trow.compute_bounds(this.el, out bounds);",
1477             "\t//GLib.debug(\"click x=%d, y=%d, w=%d, h=%d\", ",
1478             "\t//\t(int)bounds.get_x(), (int)bounds.get_y(),",
1479             "\t//\t(int)bounds.get_width(), (int)bounds.get_height()",
1480             "\t//\t);",
1481             "\tvar ypos = y - bounds.get_y();",
1482             "\t//GLib.debug(\"rel ypos = %d\", (int)ypos);\t",
1483             "\tvar rpos = 100.0 * (ypos / bounds.get_height());",
1484             "\t//GLib.debug(\"rel pos = %d %%\", (int)rpos);",
1485             "\tpos = \"over\";",
1486             "\t",
1487             "\tif (rpos > 80) {",
1488             "\t\tpos = \"below\";",
1489             "\t} else if (rpos < 20) {",
1490             "\t\tpos = \"above\";",
1491             "\t} ",
1492             "\treturn rn;",
1493             " }"
1494            ],
1495            "| void show" : [
1496             "(Gee.ArrayList<Lsp.DocumentSymbol> syms) {",
1497             "\t",
1498             "\tif (!_this.navigation_holder.el.visible) {",
1499             "\t\t_this.navigation_holder.el.show();",
1500             "\t\t_this.paned.el.position  = ",
1501             "\t\t\t_this.paned.el.get_width() - 200;",
1502             "\t}",
1503             "\t//_this.navliststore.el.remove_all();",
1504             "\t",
1505             "\t",
1506             "\tvar ls  = new GLib.ListStore(typeof(Lsp.DocumentSymbol));",
1507             "\t",
1508             "\tforeach(var sym in syms) {",
1509             "\t\tls.append(sym);",
1510             "\t}",
1511             "\tLsp.DocumentSymbol.copyList(ls, _this.navliststore.el);",
1512             "\t//_this.navliststore.el.append(sym);",
1513             "\tthis.last_selected_line = -1;",
1514             "\tGLib.Idle.add(() => {",
1515             "\t\t_this.navigationsort.collapseOnLoad();",
1516             "\t\tGtk.TextIter iter;",
1517             "\t\t_this.buffer.el.get_iter_at_offset (",
1518             "\t\t\t\tout iter, _this.buffer.el.cursor_position);",
1519             "\t\t",
1520             "\t\tGLib.debug(\"idle update scroll %d, %d\", iter.get_line(),",
1521             "\t\t\t\titer.get_line_offset());",
1522             "\t\tthis.updateSelectedLine(",
1523             "\t\t\t\t(uint)iter.get_line(),",
1524             "\t\t\t\t(uint)iter.get_line_offset()",
1525             "\t\t);",
1526             "\t\treturn false;",
1527             "\t});",
1528             "",
1529             "}"
1530            ],
1531            "| void updateSelectedLine" : [
1532             "(uint line, uint chr) {",
1533             "\tif (line == this.last_selected_line) {",
1534             "\t\treturn;",
1535             "\t}",
1536             "\tGLib.debug(\"select line %d\", (int)line);",
1537             "\tthis.last_selected_line = (int)line;",
1538             "\t",
1539             "\t",
1540             "\tvar new_row = -1;",
1541             "\tvar sym = _this.navliststore.symbolAtLine(line, chr);",
1542             "\tif (sym != null) {",
1543             "\t \tnew_row = _this.navigationsort.getRowFromSymbol(sym);",
1544             " \t\tGLib.debug(\"select line %d - row found %d\", (int)line, new_row);",
1545             " \t} else {",
1546             " \t\tGLib.debug(\" no symbol found at line %d\", (int)line);",
1547             " \t}",
1548             " \t",
1549             "\tif (this.selected_row != null) { ",
1550             "\t\tGLib.debug(\" remove selected row\");",
1551             "\t\tthis.selected_row.remove_css_class(\"selected-row\");",
1552             "\t}",
1553             "\tthis.selected_row  = null;",
1554             "\tif (new_row > -1) {",
1555             "\t\tthis.el.scroll_to(new_row,null,Gtk.ListScrollFlags.NONE, null);",
1556             "\t\tvar row = sym.get_data<Gtk.Widget>(\"widget\");",
1557             "\t\tif (row != null) {",
1558             "\t\t\tGLib.debug(\" Add selected row\");",
1559             " \t\t\t",
1560             "\t\t\trow.add_css_class(\"selected-row\");",
1561             "\t\t\tthis.selected_row = row;",
1562             "",
1563             "\t\t\t",
1564             "\t\t} else {",
1565             "\t\t\tGLib.debug(\"could not find widget on row %d\", new_row);",
1566             "\t\t}",
1567             "",
1568             "\t}",
1569             "",
1570             "",
1571             "}"
1572            ]
1573           }
1574          ],
1575          "xtype" : "ScrolledWindow"
1576         }
1577        ],
1578        "xtype" : "Box"
1579       }
1580      ],
1581      "xtype" : "Paned"
1582     }
1583    ],
1584    "xtype" : "Box",
1585    "| bool saveContents" : [
1586     "  ()  {",
1587     "    ",
1588     "    ",
1589     "    if (_this.file == null) {",
1590     "        return true;",
1591     "    }",
1592     "    ",
1593     "     ",
1594     "     ",
1595     "     var str = _this.buffer.toString();",
1596     "     ",
1597     "     _this.buffer.checkSyntax();",
1598     "     ",
1599     "     ",
1600     "     ",
1601     "     // LeftPanel.model.changed(  str , false);",
1602     "     _this.dirty = false;",
1603     "     _this.save_button.el.sensitive = false;",
1604     "     ",
1605     "    // find the text for the node..",
1606     "    if (_this.file.xtype != \"PlainFile\") {",
1607     "       // in theory these properties have to exist!?!",
1608     "    \tthis.prop.val = str;",
1609     "        //this.window.windowstate.left_props.reload();",
1610     "    } else {",
1611     "        _this.file.setSource(  str );",
1612     "     }",
1613     "    ",
1614     "    // call the signal..",
1615     "    this.save();",
1616     "    ",
1617     "    return true;",
1618     "",
1619     "} "
1620    ],
1621    "| int search" : [
1622     "(string in_txt) {",
1623     "",
1624     "\tvar s = new GtkSource.SearchSettings();",
1625     "\ts.case_sensitive = _this.case_sensitive.el.active;",
1626     "\ts.regex_enabled = _this.regex.el.active;\t",
1627     "\ts.wrap_around = false;",
1628     "\t",
1629     "\tthis.searchcontext = new GtkSource.SearchContext(this.buffer.el,s);",
1630     "\tthis.searchcontext.set_highlight(true);",
1631     "\tvar txt = in_txt;",
1632     "\t",
1633     "\tif (_this.multiline.el.active) {",
1634     "\t\ttxt = in_txt.replace(\"\\\\n\", \"\\n\");",
1635     "\t}",
1636     "\t",
1637     "\ts.set_search_text(txt);",
1638     "\tGtk.TextIter beg, st,en;",
1639     "\t ",
1640     "\tthis.buffer.el.get_start_iter(out beg);",
1641     "\tbool has_wrapped_around;",
1642     "\tthis.searchcontext.forward(beg, out st, out en, out has_wrapped_around);",
1643     "\tthis.last_search_end = 0;",
1644     "\t",
1645     "\treturn this.searchcontext.get_occurrences_count();",
1646     "",
1647     " ",
1648     "   ",
1649     "",
1650     "}",
1651     ""
1652    ],
1653    "| string tempFileContents" : [
1654     "() {",
1655     "   ",
1656     "   ",
1657     "   if (_this.file == null) {",
1658     "       return \"\";",
1659     "   }",
1660     "\tvar str= this.buffer.toString();",
1661     "\tif (_this.file.xtype == \"PlainFile\") {",
1662     "    ",
1663     "     \treturn str;",
1664     "    ",
1665     "    }",
1666     "  ",
1667     "      ",
1668     "     ",
1669     "    GLib.debug(\"calling validate\");    ",
1670     "    // clear the buttons.",
1671     " \tif (_this.prop.name == \"xns\" || _this.prop.name == \"xtype\") {",
1672     "\t\treturn this.file.toSource(); ;",
1673     "\t}",
1674     "\t",
1675     "\tvar oldcode  = _this.prop.val;",
1676     "\t_this.prop.val = str;",
1677     "    var ret = _this.file.toSource();",
1678     "    _this.prop.val = oldcode;",
1679     "    return ret;",
1680     "    ",
1681     "}"
1682    ],
1683    "| void backSearch" : [
1684     "(bool change_focus) {",
1685     "",
1686     "\tif (this.searchcontext == null) {",
1687     "\t\treturn;",
1688     "\t}",
1689     "\t",
1690     "\tGtk.TextIter beg, st,en;",
1691     "\tbool has_wrapped_around;",
1692     "\tthis.buffer.el.get_iter_at_offset(out beg, this.last_search_end -1 );",
1693     "\t",
1694     "\tif (!this.searchcontext.backward(beg, out st, out en, out has_wrapped_around)) {",
1695     "\t\tthis.last_search_end = 0;",
1696     "\t} else {",
1697     "\t\tthis.last_search_end = en.get_offset();",
1698     "\t\tif (change_focus) {",
1699     "\t\t\tthis.view.el.grab_focus();",
1700     "\t\t}",
1701     "\t\tthis.buffer.el.place_cursor(st);",
1702     "\t\tthis.view.el.scroll_to_iter(st,  0.1f, true, 0.0f, 0.5f);",
1703     "\t}",
1704     "",
1705     "}",
1706     ""
1707    ],
1708    "| void forwardSearch" : [
1709     "(bool change_focus) {",
1710     "",
1711     "\tif (this.searchcontext == null) {",
1712     "\t\treturn;",
1713     "\t} ",
1714     "",
1715     "\tGtk.TextIter beg, st,en;",
1716     "\t bool has_wrapped_around;",
1717     "\tthis.buffer.el.get_iter_at_offset(out beg, this.last_search_end);",
1718     "\tif (!this.searchcontext.forward(beg, out st, out en, out has_wrapped_around)) {",
1719     "\t",
1720     "\t\tthis.last_search_end = 0; // not sure if this should happen",
1721     "\t} else {",
1722     "\t\tif (has_wrapped_around) {",
1723     "\t\t\treturn;",
1724     "\t\t}",
1725     "\t",
1726     "\t\tthis.last_search_end = en.get_offset();",
1727     "\t\tif (change_focus) {",
1728     "\t\t\tthis.view.el.grab_focus();",
1729     "\t\t}",
1730     "\t\tthis.buffer.el.place_cursor(st);",
1731     "\t\tthis.view.el.scroll_to_iter(st,  0.1f, true, 0.0f, 0.5f);",
1732     "\t}",
1733     " ",
1734     "}",
1735     ""
1736    ],
1737    "| void reset" : [
1738     "() {",
1739     "\t this.file = null;    ",
1740     "     ",
1741     "    this.node = null;",
1742     "    this.prop = null;",
1743     "\tthis.searchcontext = null;",
1744     "  ",
1745     "}",
1746     ""
1747    ],
1748    "| void scroll_to_line" : [
1749     "(int line) {",
1750     "",
1751     "\tGLib.Timeout.add(500, () => {",
1752     "   ",
1753     "\t\tvar buf = this.view.el.get_buffer();",
1754     "",
1755     "\t\tvar sbuf = (GtkSource.Buffer) buf;",
1756     "",
1757     "",
1758     "\t\tGtk.TextIter iter;   ",
1759     "\t\tsbuf.get_iter_at_line(out iter,  line);",
1760     "\t\tthis.view.el.scroll_to_iter(iter,  0.1f, true, 0.0f, 0.5f);",
1761     "\t\treturn false;",
1762     "\t});   ",
1763     "}",
1764     ""
1765    ],
1766    "| void show" : [
1767     "(JsRender.JsRender file, JsRender.Node? node, JsRender.NodeProp? prop)",
1768     "{",
1769     "    this.reset();",
1770     "    if (this.file != null) {",
1771     "    \tthis.file.navigation_tree_updated.disconnect(",
1772     "    \t\t_this.navigation.show",
1773     "    \t);",
1774     "    }",
1775     "    this.file = file;    ",
1776     "    this.file.navigation_tree_updated.connect(",
1777     "\t\t_this.navigation.show",
1778     "\t);",
1779     "    if (file.xtype != \"PlainFile\") {",
1780     "    \tthis.prop = prop;",
1781     "        this.node = node;",
1782     "",
1783     "        // find the text for the node..",
1784     "        this.view.load( prop.val );",
1785     "        this.updateErrorMarks();",
1786     "        ",
1787     "        ",
1788     "        ",
1789     "        this.close_btn.el.show();       ",
1790     "    ",
1791     "    } else {",
1792     "        this.view.load(        file.toSource() );",
1793     "        this.updateErrorMarks();",
1794     "        this.close_btn.el.hide();",
1795     "        var ls = file.getLanguageServer();",
1796     "        ls.queueDocumentSymbols(file);",
1797     "        ////ls.documentSymbols.begin(file, (a,o) => {",
1798     "        //\t_this.navigation.show(ls.documentSymbols.end(o)); ",
1799     "       //});",
1800     "        //documentSymbols",
1801     "        ",
1802     "    }",
1803     " ",
1804     "}"
1805    ],
1806    "| void updateErrorMarks" : [
1807     "() {",
1808     "\t",
1809     " ",
1810     "",
1811     "\tvar buf = _this.buffer.el;",
1812     "\tGtk.TextIter start;",
1813     "\tGtk.TextIter end;     ",
1814     "\tbuf.get_bounds (out start, out end);",
1815     "",
1816     "\t",
1817     "",
1818     " ",
1819     "\t//GLib.debug(\"highlight errors\");\t\t ",
1820     "",
1821     "\t // we should highlight other types of errors..",
1822     "",
1823     "\tif (_this.window.windowstate.state != WindowState.State.CODEONLY ",
1824     "\t\t&&",
1825     "\t\t_this.window.windowstate.state != WindowState.State.CODE",
1826     "\t\t) {",
1827     "\t\t//GLib.debug(\"windowstate != CODEONLY?\");",
1828     "\t\t",
1829     "\t\treturn;",
1830     "\t} ",
1831     "",
1832     "\t ",
1833     "\tif (_this.file == null) {",
1834     "\t\tGLib.debug(\"file is null?\");",
1835     "\t\treturn;",
1836     "",
1837     "\t}",
1838     "\tvar ar = this.file.getErrors();",
1839     "\tif (ar.size < 1) {",
1840     "\t\tbuf.remove_source_marks (start, end, \"ERR\");",
1841     "\t\tbuf.remove_source_marks (start, end, \"WARN\");",
1842     "\t\tbuf.remove_source_marks (start, end, \"DEPR\");",
1843     "\t\tbuf.remove_tag_by_name (\"ERR\", start, end);",
1844     "\t\tbuf.remove_tag_by_name (\"WARN\", start, end);",
1845     "\t\tbuf.remove_tag_by_name (\"DEPR\", start, end);",
1846     "\t\tthis.last_error_counter = file.error_counter ;",
1847     "\t\t//GLib.debug(\"highlight %s :  %s has no errors\", this.file.relpath, category);",
1848     "\t\treturn;",
1849     "\t}",
1850     "\t",
1851     "",
1852     " // basicaly check if there is no change, then we do not do any update..",
1853     " // we can do this by just using an error counter?",
1854     " // if that's changed then we will do an update, otherwise dont bother.",
1855     "\t  ",
1856     "\t",
1857     "\tvar offset = 0;",
1858     "\tvar hoffset = 0;",
1859     "",
1860     "\tvar tlines = buf.get_line_count () +1;",
1861     "\t",
1862     "\tif (_this.prop != null) {",
1863     "\t\t// this still seems flaky...",
1864     "",
1865     "\t\ttlines = _this.prop.end_line;",
1866     "\t\toffset = _this.prop.start_line;",
1867     "\t\thoffset = _this.node.node_pad.length + 2; //shift it left  by 2 ? ..",
1868     "\t\t",
1869     "\t\t ",
1870     "\t} else {",
1871     "\t\t// no update...",
1872     "\t\tif (this.last_error_counter == file.error_counter) {",
1873     "\t\t",
1874     "\t\t\treturn;",
1875     "\t\t}",
1876     "\t",
1877     "\t}",
1878     "\tbuf.remove_source_marks (start, end, \"ERR\");",
1879     "\tbuf.remove_source_marks (start, end, \"WARN\");",
1880     "\tbuf.remove_source_marks (start, end, \"DEPR\");",
1881     "\tbuf.remove_tag_by_name (\"ERR\", start, end);",
1882     "\tbuf.remove_tag_by_name (\"WARN\", start, end);",
1883     "\tbuf.remove_tag_by_name (\"DEPR\", start, end);",
1884     "\t",
1885     "\tforeach(var diag in ar) { ",
1886     "\t     Gtk.TextIter iter;",
1887     "//        print(\"get inter\\n\");",
1888     "\t    var eline = (int)diag.range.start.line - offset;",
1889     "\t    var eline_to = (int)diag.range.end.line - offset;",
1890     "\t    //var eline =  diag.range.end_line - offset;",
1891     "\t    //GLib.debug(\"GOT ERROR on line %d -- converted to %d  (offset = %d)\",",
1892     "\t    //\terr.line ,eline, offset);",
1893     "\t    ",
1894     "\t    ",
1895     "\t    if (eline > tlines || eline < 0) {",
1896     "\t        continue;",
1897     "\t    }",
1898     "\t    ",
1899     "\t    buf.get_iter_at_line( out iter, eline);",
1900     "\t   \tvar msg = \"Line: %d %s : %s\".printf(eline+1, diag.category, diag.message);",
1901     "\t    buf.create_source_mark( msg, diag.category, iter);",
1902     "\t    ",
1903     " \t    var spos = (int)diag.range.start.character - hoffset;",
1904     " \t    if (spos < 0) { spos =0 ; }",
1905     " \t    if (spos > iter.get_chars_in_line()) {",
1906     " \t    \tspos = iter.get_chars_in_line();",
1907     "    \t}",
1908     "\t\tbuf.get_iter_at_line( out iter, eline_to);",
1909     "\t\tvar epos = (int)diag.range.end.character - hoffset;",
1910     " \t    if (epos < 0) { epos =0 ; }",
1911     " \t    if (epos > iter.get_chars_in_line()) {",
1912     " \t    \tepos = iter.get_chars_in_line();",
1913     "    \t}",
1914     " \t     ",
1915     " \t    ",
1916     " \t    buf.get_iter_at_line_offset( out start, eline, spos); ",
1917     " \t   ",
1918     " \t    buf.get_iter_at_line_offset( out end, eline_to,epos); ",
1919     " \t    \t",
1920     "\t    buf.apply_tag_by_name(diag.category, start, end);",
1921     "\t    ",
1922     "\t   // GLib.debug(\"set line %d to %s\", eline, msg);",
1923     "\t    //this.marks.set(eline, msg);",
1924     "\t}",
1925     "\tthis.last_error_counter = file.error_counter ;",
1926     "",
1927     "",
1928     "",
1929     " ",
1930     "",
1931     "}"
1932    ]
1933   }
1934  ],
1935  "name" : "Editor"
1936 }