Merge branch 'master' of http://git.roojs.com/roobuilder
[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            "listeners" : {
72             "activate_link" : [
73              "(uri) => {",
74              "\tGLib.debug(\"got uri %s\", uri);",
75              "\tvar ls = _this.file.getLanguageServer();",
76              "\tls.symbol.begin(uri, (a,b) => {",
77              "\t\tls.symbol.end(b);",
78              "\t});",
79              "\t",
80              "\treturn true;",
81              "}",
82              ""
83             ],
84             "query_tooltip" : [
85              "(x, y, keyboard_tooltip, tooltip) => {",
86              "\tGLib.debug(\"using quiery tooltip?\");",
87              "\tvar lbl = new Gtk.Label(this.el.tooltip_markup);",
88              "\tlbl.width_request = 500;",
89              "\ttooltip.set_custom(lbl);",
90              "",
91              "\treturn true;",
92              "}",
93              ""
94             ]
95            },
96            "xtype" : "Label",
97            "| void setHelp" : [
98             "(Lsp.Hover? help) {",
99             "\tif (help == null || help.contents == null",
100             "\t\t|| help.contents.size < 1) {",
101             "\t\tthis.el.set_text(\"\");",
102             "\t\treturn;",
103             "\t}",
104             "\tvar sig = help.contents.get(0).value.split(\" \");",
105             "\tstring[] str = {};",
106             "\tfor(var i =0; i < sig.length; i++) {",
107             "\t",
108             "\t\tswitch(sig[i]) {",
109             "\t\t\tcase \"public\":",
110             "\t\t\tcase \"private\":",
111             "\t\t\tcase \"protected\":",
112             "\t\t\tcase \"async\":",
113             "\t\t\tcase \"class\":",
114             "\t\t\tcase \"{\":",
115             "\t\t\tcase \"}\":",
116             "\t\t\tcase \"(\":",
117             "\t\t\tcase \")\":",
118             "\t\t\t",
119             "\t\t\t\tstr += sig[i];",
120             "\t\t\t\tcontinue;",
121             "\t\t\t\t",
122             "\t\t\t\t",
123             "\t\t\tdefault:",
124             "\t",
125             "\t\t\t\tstr += (\"<a href=\\\"\" + GLib.Markup.escape_text(sig[i]) + \"\\\">\" + ",
126             "\t\t\t\t\tGLib.Markup.escape_text(sig[i])",
127             "\t\t\t\t\t+\"</a>\");",
128             "\t\t\tcontinue;",
129             "\t\t}",
130             "\t}",
131             "\tif (help.contents.size > 1) {",
132             "\t\tthis.el.tooltip_markup =  GLib.Markup.escape_text(help.contents.get(1).value);",
133             "\t} else {",
134             "\t\tthis.el.tooltip_markup = GLib.Markup.escape_text(help.contents.get(0).value);",
135             "\t}",
136             "\tthis.el.set_markup(string.joinv(\" \",str));",
137             "\t",
138             "}"
139            ]
140           },
141           {
142            "$ xns" : "Gtk",
143            "* ctor" : "new Gtk.Scale.with_range (Gtk.Orientation.HORIZONTAL,6, 30, 1)",
144            "* init" : [
145             "{",
146             "\t//this.el.set_range(6,30);",
147             " \tthis.el.set_value ( BuilderApplication.settings.editor_font_size);",
148             " \tBuilderApplication.settings.editor_font_size_updated.connect(",
149             " \t\t() => {",
150             " \t\t\tBuilderApplication.settings.editor_font_size_inchange = true;",
151             " \t\t//\tGLib.debug(\"update range\");",
152             " \t\t \tthis.el.set_value (BuilderApplication.settings.editor_font_size);",
153             " \t\t \tBuilderApplication.settings.editor_font_size_inchange = false;",
154             " \t\t}",
155             "\t);",
156             "\t",
157             " ",
158             "}",
159             ""
160            ],
161            "Gtk.Align halign" : "Gtk.Align.END",
162            "bool draw_value" : false,
163            "bool has_origin" : true,
164            "bool sensitive" : true,
165            "int digits" : 0,
166            "int width_request" : 150,
167            "listeners" : {
168             "change_value" : [
169              "(st, val ) => {",
170              "\tif (BuilderApplication.settings.editor_font_size_inchange) {",
171              "\t\treturn false;",
172              "\t}",
173              "  \tBuilderApplication.settings.editor_font_size = val;",
174              " \treturn false;",
175              "}"
176             ]
177            },
178            "xtype" : "Scale"
179           },
180           {
181            "$ xns" : "Gtk",
182            "Gtk.Align halign" : "Gtk.Align.END",
183            "id" : "close_btn",
184            "items" : [
185             {
186              "$ xns" : "Gtk",
187              "* prop" : "child",
188              "Gtk.IconSize icon_size" : "Gtk.IconSize.NORMAL",
189              "string icon_name" : "window-close",
190              "xtype" : "Image"
191             }
192            ],
193            "listeners" : {
194             "clicked" : [
195              " () => { ",
196              "    _this.saveContents();",
197              "    _this.window.windowstate.switchState(WindowState.State.PREVIEW);",
198              "}",
199              "  "
200             ]
201            },
202            "string icon_name" : "window-close",
203            "xtype" : "Button"
204           }
205          ],
206          "xtype" : "Box"
207         },
208         {
209          "$ xns" : "Gtk",
210          "Gtk.PolicyType hscrollbar_policy" : "Gtk.PolicyType.AUTOMATIC",
211          "Gtk.PolicyType vscrollbar_policy" : "Gtk.PolicyType.AUTOMATIC",
212          "bool overlay_scrolling" : false,
213          "bool vexpand" : true,
214          "id" : "RightEditor",
215          "items" : [
216           {
217            "# Gtk.CssProvider css" : "null",
218            "$ gboolean auto_indent" : true,
219            "$ xns" : "GtkSource",
220            "* init" : [
221             "",
222             " ",
223             "\t",
224             " ",
225             " ",
226             "this.el.completion.add_provider(",
227             "\tnew Palete.CompletionProvider(_this)",
228             ");",
229             "",
230             "// hover seems pretty useless.. - ??",
231             "//var hover = this.el.get_hover();",
232             "//hover.add_provider(new Palete.HoverProvider(_this));",
233             "",
234             "//this.el.completion.unblock_interactive();",
235             "this.el.completion.select_on_show = true; // select",
236             "//this.el.completion.remember_info_visibility\t = true;",
237             "",
238             "",
239             "var attrs = new GtkSource.MarkAttributes();",
240             "",
241             "attrs.set_icon_name ( \"process-stop\");    ",
242             "attrs.query_tooltip_text.connect(( mark) => {",
243             "     GLib.debug(\"tooltip query? %s\", mark.name);",
244             "    return strdup( mark.name);",
245             "});",
246             " attrs.query_tooltip_markup.connect(( mark) => {",
247             "     GLib.debug(\"tooltip query? %s\", mark.name);",
248             "    return strdup( mark.name);",
249             "});",
250             "this.el.set_mark_attributes (\"ERR\", attrs, 1);",
251             "attrs.ref();",
252             "",
253             "",
254             "var wattrs = new GtkSource.MarkAttributes();",
255             "wattrs.set_icon_name ( \"process-stop\");    ",
256             "wattrs.query_tooltip_text.connect(( mark) => {",
257             "     GLib.debug(\"tooltip query? %s\", mark.name);",
258             "    return strdup(mark.name);",
259             "});",
260             "wattrs.query_tooltip_markup.connect(( mark) => {",
261             "     GLib.debug(\"tooltip query? %s\", mark.name);",
262             "    return strdup(mark.name);",
263             "});",
264             "this.el.set_mark_attributes (\"WARN\", wattrs, 1);",
265             "wattrs.ref();",
266             "",
267             " ",
268             "var dattrs = new GtkSource.MarkAttributes();",
269             " ",
270             "dattrs.set_icon_name ( \"process-stop\"); ",
271             "",
272             "dattrs.query_tooltip_text.connect(( mark) => {",
273             "\tGLib.debug(\"tooltip query? %s\", mark.name);",
274             "    return strdup(mark.name);",
275             "});",
276             "//dattrs.query_tooltip_markup.connect(( mark) => {",
277             "//\tGLib.debug(\"tooltip query? %s\", mark.name);",
278             " //   return strdup(mark.name);",
279             "//});",
280             "this.el.set_mark_attributes (\"DEPR\", dattrs, 1);",
281             "dattrs.ref();    ",
282             "",
283             " this.el.get_space_drawer().set_matrix(null);",
284             " this.el.get_space_drawer().set_types_for_locations( ",
285             "\tGtkSource.SpaceLocationFlags.ALL,",
286             "\tGtkSource.SpaceTypeFlags.ALL",
287             ");",
288             "this.el.get_space_drawer().set_enable_matrix(true);",
289             ""
290            ],
291            "* prop" : "child",
292            "bool has_tooltip" : true,
293            "bool hexpand" : true,
294            "bool insert_spaces_instead_of_tabs" : true,
295            "bool vexpand" : true,
296            "boolean show_line_marks" : true,
297            "boolean show_line_numbers" : true,
298            "css_classes" : "{ \"code-editor\" }",
299            "gboolean highlight_current_line" : true,
300            "id" : "view",
301            "indent_width" : 4,
302            "items" : [
303             {
304              "$ Gee.HashMap<int,string>? xmarks" : "null",
305              "$ xns" : "GtkSource",
306              "$ xtype" : "Buffer",
307              "* init" : [
308               "",
309               "var buf = this.el;",
310               "buf.create_tag (\"bold\", \"weight\", Pango.Weight.BOLD);",
311               "buf.create_tag (\"type\", \"weight\", Pango.Weight.BOLD, \"foreground\", \"#204a87\");",
312               "buf.create_tag (\"keyword\", \"weight\", Pango.Weight.BOLD, \"foreground\", \"#a40000\");",
313               "buf.create_tag (\"text\", \"weight\", Pango.Weight.NORMAL, \"foreground\", \"#729fcf\");",
314               "buf.create_tag (\"number\", \"weight\", Pango.Weight.BOLD, \"foreground\", \"#ad7fa8\");",
315               "buf.create_tag (\"method\", \"weight\", Pango.Weight.BOLD, \"foreground\", \"#729fcf\");",
316               "buf.create_tag (\"property\", \"weight\", Pango.Weight.BOLD, \"foreground\", \"#BC1F51\");",
317               "buf.create_tag (\"variable\", \"weight\", Pango.Weight.BOLD, \"foreground\", \"#A518B5\");",
318               "",
319               "",
320               "buf.create_tag (\"ERR\", \"weight\", Pango.Weight.BOLD, \"background\", \"pink\");",
321               "buf.create_tag (\"WARN\", \"weight\", Pango.Weight.BOLD, \"background\", \"#ABF4EB\");",
322               "buf.create_tag (\"DEPR\", \"weight\", Pango.Weight.BOLD, \"background\", \"#EEA9FF\");",
323               "",
324               "",
325               ""
326              ],
327              "* prop" : "buffer",
328              "bool check_queued" : false,
329              "bool enable_undo" : true,
330              "bool highlight_matching_brackets" : true,
331              "bool highlight_syntax" : true,
332              "id" : "buffer",
333              "int error_line" : "-1",
334              "listeners" : {
335               "changed" : [
336                " () => {",
337                "    // check syntax??",
338                "    // ??needed..??",
339                "    _this.save_button.el.sensitive = true;",
340                "    print(\"EDITOR CHANGED\");",
341                "    this.checkSyntax();",
342                "   ",
343                "    _this.dirty = true;",
344                "",
345                "    // this.get('/LeftPanel.model').changed(  str , false);",
346                "    return ;",
347                "}",
348                ""
349               ],
350               "cursor_moved" : [
351                "( ) => {",
352                "",
353                "\tGtk.TextIter iter;",
354                "\tthis.el.get_iter_at_offset (",
355                "\t\t\tout iter, this.el.cursor_position);",
356                "",
357                "\t_this.navigation.updateSelectedLine(",
358                "\t\t\t(uint)iter.get_line(),",
359                "\t\t\t(uint)iter.get_line_offset()",
360                "\t\t);",
361                "\tthis.showHelp(iter);",
362                "",
363                "}",
364                ""
365               ]
366              },
367              "| bool OLDhighlightErrorsJson" : [
368               "(string type, Json.Object obj) {",
369               "\tGtk.TextIter start;",
370               "\tGtk.TextIter end;     ",
371               "\tthis.el.get_bounds (out start, out end);",
372               "",
373               "\tthis.el.remove_source_marks (start, end, type);",
374               "\tGLib.debug(\"highlight errors\");\t\t ",
375               "",
376               "\t // we should highlight other types of errors..",
377               "",
378               "\tif (!obj.has_member(type)) {",
379               "\t\tGLib.debug(\"Return has no errors\\n\");",
380               "\t\treturn true;",
381               "\t}",
382               "",
383               "\tif (_this.window.windowstate.state != WindowState.State.CODEONLY ",
384               "\t\t&&",
385               "\t\t_this.window.windowstate.state != WindowState.State.CODE",
386               "\t\t) {",
387               "\t\tGLib.debug(\"windowstate != CODEONLY?\");",
388               "\t\t",
389               "\t\treturn true;",
390               "\t} ",
391               "",
392               "\t//this.marks = new Gee.HashMap<int,string>();",
393               "\tvar err = obj.get_object_member(type);",
394               " ",
395               "\tif (_this.file == null) {",
396               "\t\tGLib.debug(\"file is null?\");",
397               "\t\treturn true;",
398               "",
399               "\t}",
400               "\tvar valafn = _this.file.path;",
401               "",
402               "\tif (_this.file.xtype != \"PlainFile\") {",
403               "",
404               "\t\tvalafn = \"\";",
405               "\t\ttry {             ",
406               "\t\t\tvar  regex = new Regex(\"\\\\.bjs$\");",
407               "\t\t\t// should not happen",
408               "\t      \t\tvalafn = regex.replace(_this.file.path,_this.file.path.length , 0 , \".vala\");",
409               "\t\t} catch (GLib.RegexError e) {",
410               "\t\t\treturn true;",
411               "\t\t}   ",
412               "",
413               "",
414               "",
415               "\t}",
416               "\tif (!err.has_member(valafn)) {",
417               "\t\tGLib.debug(\"File path has no errors\");",
418               "\t\treturn  true;",
419               "\t}",
420               "",
421               "\tvar lines = err.get_object_member(valafn);",
422               "\t",
423               "\tvar offset = 1;",
424               "\tif (obj.has_member(\"line_offset\")) { // ?? why??",
425               "\t\toffset = (int)obj.get_int_member(\"line_offset\") + 1;",
426               "\t}",
427               "",
428               "",
429               "\tvar tlines = this.el.get_line_count () +1;",
430               "\t",
431               "\tif (_this.prop != null) {",
432               "\t",
433               "\t\ttlines = _this.prop.end_line + 1;",
434               "\t\toffset = _this.prop.start_line + 1;",
435               "\t",
436               "\t}",
437               "\t",
438               "",
439               "",
440               "\tlines.foreach_member((obj, line, node) => {",
441               "\t\t",
442               "\t     Gtk.TextIter iter;",
443               "//        print(\"get inter\\n\");",
444               "\t    var eline = int.parse(line) - offset;",
445               "\t    GLib.debug(\"GOT ERROR on line %s -- converted to %d  (offset = %d)\\n\", line,eline, offset);",
446               "\t    ",
447               "\t    ",
448               "\t    if (eline > tlines || eline < 0) {",
449               "\t        return;",
450               "\t    }",
451               "\t   ",
452               "\t    ",
453               "\t    this.el.get_iter_at_line( out iter, eline);",
454               "\t    //print(\"mark line\\n\");",
455               "\t    var msg  = \"\";",
456               "\t    var ar = lines.get_array_member(line);",
457               "\t    for (var i = 0 ; i < ar.get_length(); i++) {",
458               "\t    \tif (ar.get_string_element(i) == \"Success\") {",
459               "\t    \t\tcontinue;",
460               "    \t\t}",
461               "\t\t\tmsg += (msg.length > 0) ? \"\\n\" : \"\";",
462               "\t\t\tmsg += ar.get_string_element(i);",
463               "\t\t}",
464               "\t\tif (msg == \"\") {",
465               "\t\t\treturn;",
466               "\t\t}",
467               "\t\tmsg = \"Line: %d\".printf(eline+1) +  \" \" + msg;",
468               "\t    this.el.create_source_mark(msg, type, iter);",
469               "\t    GLib.debug(\"set line %d to %m\", eline, msg);",
470               "\t   // this.marks.set(eline, msg);",
471               "\t} );",
472               "\treturn false;",
473               "",
474               "",
475               "",
476               "",
477               "",
478               "\t}",
479               ""
480              ],
481              "| bool checkSyntax" : [
482               " () {",
483               " ",
484               "    ",
485               "    var str = this.toString();",
486               "    ",
487               "    // needed???",
488               "    if (this.error_line > 0) {",
489               "         Gtk.TextIter start;",
490               "         Gtk.TextIter end;     ",
491               "        this.el.get_bounds (out start, out end);",
492               "",
493               "        this.el.remove_source_marks (start, end, null);",
494               "    }",
495               "    if (str.length < 1) {",
496               "        print(\"checkSyntax - empty string?\\n\");",
497               "        return true;",
498               "    }",
499               "    ",
500               "    // bit presumptiona",
501               "    if (_this.file.xtype == \"PlainFile\") {",
502               "    ",
503               "        // assume it's gtk...",
504               "         var  oldcode =_this.file.toSource();",
505               "        _this.file.setSource(str);",
506               "\t    BuilderApplication.showSpinner(\"appointment soon\",\"document change pending\");",
507               "    \t_this.file.getLanguageServer().document_change(_this.file);",
508               "\t\t_this.file.getLanguageServer().queueDocumentSymbols(_this.file);",
509               "        _this.file.setSource(oldcode);",
510               "        ",
511               "\t\t ",
512               "        return true;",
513               "    ",
514               "    }",
515               "   if (_this.file == null) {",
516               "       return true;",
517               "   }",
518               " ",
519               "    ",
520               "",
521               "      ",
522               "     ",
523               "    GLib.debug(\"calling validate\");    ",
524               "    // clear the buttons.",
525               " \tif (_this.prop.name == \"xns\" || _this.prop.name == \"xtype\") {",
526               "\t\treturn true ;",
527               "\t}",
528               "\tvar oldcode  = _this.prop.val;",
529               "\t",
530               "\t_this.prop.val = str;",
531               "\t_this.node.updated_count++;",
532               "    _this.file.getLanguageServer().document_change(_this.file);",
533               "    _this.node.updated_count++;",
534               "    _this.prop.val = oldcode;",
535               "    ",
536               "    ",
537               "    //print(\"done mark line\\n\");",
538               "     ",
539               "    return true; // at present allow saving - even if it's invalid..",
540               "}",
541               ""
542              ],
543              "| bool highlightErrors" : [
544               "( Gee.HashMap<int,string> validate_res) {",
545               "         ",
546               "\tthis.error_line = validate_res.size;",
547               "",
548               "\tif (this.error_line < 1) {",
549               "\t\treturn true;",
550               "\t}",
551               "\tvar tlines = this.el.get_line_count ();",
552               "\tGtk.TextIter iter;",
553               "\tvar valiter = validate_res.map_iterator();",
554               "\twhile (valiter.next()) {",
555               "",
556               "\t//        print(\"get inter\\n\");",
557               "\t\tvar eline = valiter.get_key();",
558               "\t\tif (eline > tlines) {",
559               "\t\t\tcontinue;",
560               "\t\t}",
561               "\t\tthis.el.get_iter_at_line( out iter, eline);",
562               "\t\t//print(\"mark line\\n\");",
563               "\t\tthis.el.create_source_mark(valiter.get_value(), \"ERR\", iter);",
564               "\t}   ",
565               "\treturn false;",
566               "}"
567              ],
568              "| string toString" : [
569               "  () {",
570               "    ",
571               "    Gtk.TextIter s;",
572               "    Gtk.TextIter e;",
573               "    this.el.get_start_iter(out s);",
574               "    this.el.get_end_iter(out e);",
575               "    var ret = this.el.get_text(s,e,true);",
576               "    //print(\"TO STRING? \" + ret);",
577               "    return ret;",
578               "}",
579               " "
580              ],
581              "| void showHelp" : [
582               "(Gtk.TextIter iter) {",
583               "\tvar back = iter.copy();",
584               "\tback.backward_char();",
585               "\t",
586               "\tvar forward = iter.copy();",
587               "\tforward.forward_char();",
588               "\t",
589               "\t// what's the character at the iter?",
590               "\tvar str = back.get_text(iter);",
591               "\tstr += iter.get_text(forward);",
592               "\tif (str.strip().length < 1) {",
593               "\t\treturn;",
594               "\t}",
595               "\tvar offset = iter.get_line_offset();",
596               "\tvar line = iter.get_line();",
597               "\tif (_this.prop != null) {",
598               "\t\t\t\t// ",
599               "\t\tline += _this.prop.start_line ; ",
600               "\t\t\t\t\t// this is based on Gtk using tabs (hence 1/2 chars);",
601               "\t\toffset += _this.node.node_pad.length;",
602               "\t\t\t\t\t// javascript listeners are indented 2 more spaces.",
603               "\t\tif (_this.prop.ptype == JsRender.NodePropType.LISTENER) {",
604               "\t\t\toffset += 2;",
605               "\t\t}",
606               "\t} ",
607               "\t",
608               "\tvar ls = _this.file.getLanguageServer();",
609               "\tls.hover.begin(",
610               "\t\t_this.file, line, offset,",
611               "\t\t( a, o)  => {",
612               "\t\t\ttry {",
613               "\t\t\t\tvar res = ls.hover.end(o );",
614               "\t\t\t",
615               "\t\t\t\t_this.helper.setHelp(res);",
616               "\t\t\t} catch (GLib.Error e) {",
617               "\t\t\t\t// noop..",
618               "\t\t\t}",
619               "\t\t});",
620               "}\t",
621               "\t\t ",
622               ""
623              ]
624             },
625             {
626              "# bool is_control" : false,
627              "$ xns" : "Gtk",
628              "id" : "keystate",
629              "listeners" : {
630               "key_pressed" : [
631                "(keyval, keycode, state) => {",
632                "",
633                " \tif (keyval == Gdk.Key.Control_L || keyval == Gdk.Key.Control_R) {",
634                " \t\tthis.is_control = true;",
635                "\t}",
636                "\treturn false;",
637                "}",
638                ""
639               ],
640               "key_released" : [
641                "(keyval, keycode, state) => {",
642                "",
643                " \t if (keyval == Gdk.Key.Control_L || keyval == Gdk.Key.Control_R) {",
644                " \t\tthis.is_control = false;",
645                "\t}",
646                "    if (keyval == Gdk.Key.s && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {",
647                "        GLib.debug(\"SAVE: ctrl-S  pressed\");",
648                "        _this.saveContents();",
649                "        return;",
650                "    }",
651                "    ",
652                "    if (keyval == Gdk.Key.g && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {",
653                "\t    GLib.debug(\"SAVE: ctrl-g  pressed\");",
654                "\t\t_this.forwardSearch(true);",
655                "\t    return;",
656                "\t}",
657                "\tif (keyval == Gdk.Key.f && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {",
658                "\t    GLib.debug(\"SAVE: ctrl-f  pressed\");",
659                "\t\t_this.search_entry.el.grab_focus();",
660                "\t\t_this.search_entry.el.select_region(0,-1);",
661                "\t    return;",
662                "\t}",
663                "\tif (keyval == Gdk.Key.space && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {",
664                "\t\t_this.view.el.show_completion();",
665                "\t}",
666                "\t",
667                "\tGtk.TextIter iter;",
668                "\t_this.buffer.el.get_iter_at_offset( out iter, _this.buffer.el.cursor_position);  ",
669                "\tvar line  = iter.get_line();",
670                "\tvar offset = iter.get_line_offset();",
671                "\tGLib.debug(\"line  %d  off %d\", line ,offset);",
672                "\tif (_this.prop != null) {",
673                "\t\tline += _this.prop.start_line + 1; // i think..",
674                "\t\toffset += 12; // should probably be 8 without namespaced ",
675                "\t\tGLib.debug(\"guess line  %d  off %d\", line ,offset);",
676                "\t} ",
677                "    //_this.view.el.show_completion();",
678                "   // print(event.key.keyval)",
679                "    ",
680                "    ",
681                "    return;",
682                " ",
683                " ",
684                "}",
685                ""
686               ]
687              },
688              "xtype" : "EventControllerKey"
689             },
690             {
691              "# double distance" : "0.0f",
692              "$ xns" : "Gtk",
693              "Gtk.EventControllerScrollFlags flags" : "Gtk.EventControllerScrollFlags.VERTICAL",
694              "listeners" : {
695               "scroll" : [
696                "(dx, dy) => {",
697                "\tif (!_this.keystate.is_control) {",
698                "\t\treturn false;",
699                "\t}",
700                "\t //GLib.debug(\"scroll %f\",  dy);",
701                "\t",
702                "\tthis.distance += dy;",
703                "\t",
704                "\t//GLib.debug(\"scroll %f / %f\",  dy, this.distance);",
705                " ",
706                "\t if (this.distance < -1) {",
707                " ",
708                "\t\tBuilderApplication.settings.editor_font_size ++;",
709                "\t\tthis.distance = 0;",
710                "\t}",
711                "\tif (this.distance > 1) {",
712                "\t\tBuilderApplication.settings.editor_font_size --;",
713                "\t\tthis.distance = 0;",
714                "\t}",
715                "\t ",
716                "\treturn true;",
717                "}",
718                ""
719               ]
720              },
721              "xtype" : "EventControllerScroll"
722             },
723             {
724              "$ xns" : "Gtk",
725              "listeners" : {
726               "pressed" : [
727                "(n_press, x, y) => {",
728                "\tGtk.TextIter iter;",
729                "\tint  buffer_x, buffer_y;",
730                "\tvar gut = _this.view.el.get_gutter(Gtk.TextWindowType.LEFT);",
731                "\t",
732                "\t _this.view.el.window_to_buffer_coords (Gtk.TextWindowType.TEXT,",
733                "\t\t(int)x - gut.get_width(),  (int)y,",
734                "  \t\tout  buffer_x, out  buffer_y);",
735                "\t_this.view.el.get_iter_at_location (out  iter,  ",
736                "\t\t\tbuffer_x,  buffer_y);;",
737                "\t",
738                "\t",
739                "\tif (_this.buffer.el.iter_has_context_class(iter, \"comment\") ||",
740                "\t\t_this.buffer.el.iter_has_context_class(iter, \"string\")",
741                "\t) { ",
742                "\t\treturn ;",
743                "\t}",
744                "\t_this.buffer.showHelp(iter);",
745                "\t ",
746                "\t\t ",
747                " ",
748                "}",
749                ""
750               ]
751              },
752              "xtype" : "GestureClick"
753             }
754            ],
755            "listeners" : {
756             "query_tooltip" : [
757              "(x, y, keyboard_tooltip, tooltip) => {",
758              "\t",
759              "\t//GLib.debug(\"query tooltip\");",
760              "\tGtk.TextIter iter;",
761              "\tint trailing;",
762              "\t",
763              "\tvar yoff = (int) _this.RightEditor.el.vadjustment.value;",
764              "\t",
765              "\t// I think this is problematic - if it's compliing  / updating at same time as query.",
766              "\t",
767              "\t//if (_this.window.statusbar_compile_spinner.el.spinning) {",
768              "\t//\treturn false;",
769              "\t//}",
770              "\t",
771              "\tthis.el.get_iter_at_position (out iter, out trailing,  x,  y + yoff);",
772              "\t ",
773              "\tvar l = iter.get_line();",
774              "",
775              "\t",
776              "\t ",
777              "\t// GLib.debug(\"query tooltip line %d\", (int) l);",
778              "\tif (l < 0) {",
779              "",
780              "\t\treturn false;",
781              "\t}",
782              "\t/*",
783              "\tif (_this.buffer.marks != null && _this.buffer.marks.has_key(l)) {",
784              "\t\tGLib.debug(\"line %d setting tip to %s\", l,  _this.buffer.marks.get(l));",
785              "\t\ttooltip.set_text(_this.buffer.marks.get(l).dup());",
786              "\t\treturn true;",
787              "\t}",
788              " ",
789              "\treturn false;",
790              "\t*/",
791              "\t",
792              "\t  ",
793              "\t// this crashes?? - not sure why.",
794              "\tvar marks = _this.buffer.el.get_source_marks_at_line(l, \"ERR\");",
795              "\tif (marks.is_empty()) {",
796              "\t\tmarks = _this.buffer.el.get_source_marks_at_line(l, \"WARN\");",
797              "\t}",
798              "\tif (marks.is_empty()) {",
799              "\t\tmarks = _this.buffer.el.get_source_marks_at_line(l, \"DEPR\");",
800              "\t}",
801              "\t",
802              "\t// GLib.debug(\"query tooltip line %d marks %d\", (int)l, (int) marks.length());",
803              "\tvar str = \"\";",
804              "\tmarks.@foreach((m) => { ",
805              "\t\t//GLib.debug(\"got mark %s\", m.name);",
806              "\t\tstr += (str.length > 0 ? \"\\n\" : \"\") + m.category + \": \" + m.name;",
807              "\t});",
808              "\t// true if there is a mark..",
809              "\tif (str.length > 0 ) {",
810              "\t\ttooltip.set_text( str );",
811              "\t}",
812              "\treturn str.length > 0 ? true : false;",
813              "\t ",
814              "}",
815              ""
816             ]
817            },
818            "string name" : "editor-view",
819            "uint tab_width" : 4,
820            "xtype" : "View",
821            "| void load" : [
822             " (string str) {",
823             "",
824             "// show the help page for the active node..",
825             "   //this.get('/Help').show();",
826             " ",
827             "  // this.get('/BottomPane').el.set_current_page(0);",
828             "  \tGLib.debug(\"load called - Reset undo buffer\");",
829             "  \t",
830             "    var buf = (GtkSource.Buffer)this.el.get_buffer();",
831             "    buf.begin_irreversible_action();",
832             "    buf.set_text(str, str.length);",
833             "    buf.end_irreversible_action();",
834             "    ",
835             "    var lm = GtkSource.LanguageManager.get_default();",
836             "    var lang = \"vala\";",
837             "    if (_this.file != null) {",
838             "         lang = _this.file.language;",
839             "    }",
840             "    print(\"lang=%s, content_type = %s\\n\", lang, _this.file.content_type);",
841             "    var lg = _this.file.content_type.length > 0  ?",
842             "            lm.guess_language(_this.file.path, _this.file.content_type) :",
843             "            lm.get_language(lang);",
844             "     ",
845             "   ",
846             "    ((GtkSource.Buffer)(this.el.get_buffer())) .set_language(lg); ",
847             "",
848             "    this.el.insert_spaces_instead_of_tabs = true;",
849             "    if (lg != null) {",
850             "\t\tprint(\"sourcelanguage  = %s\\n\", lg.name);",
851             "\t\tif (lg.name == \"Vala\") {",
852             "\t\t    this.el.insert_spaces_instead_of_tabs = false;",
853             "\t\t}",
854             "     }",
855             "    _this.dirty = false;",
856             "    this.el.grab_focus();",
857             "    _this.save_button.el.sensitive = false;",
858             "    _this.last_error_counter = -1;",
859             "}"
860            ]
861           }
862          ],
863          "xtype" : "ScrolledWindow"
864         },
865         {
866          "$ xns" : "Gtk",
867          "* pack" : "append",
868          "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
869          "bool homogeneous" : false,
870          "bool vexpand" : false,
871          "int spacing" : 0,
872          "items" : [
873           {
874            "$ xns" : "Gtk",
875            "Gtk.CssProvider css" : "",
876            "bool hexpand" : true,
877            "id" : "search_entry",
878            "items" : [
879             {
880              "$ xns" : "Gtk",
881              "listeners" : {
882               "key_pressed" : [
883                "(keyval, keycode, state) => {",
884                "",
885                "\tif (keyval == Gdk.Key.g && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {",
886                "\t    GLib.debug(\"SAVE: ctrl-g  pressed\");",
887                "\t\t_this.forwardSearch(true);",
888                "\t    return true;",
889                "\t}",
890                "    ",
891                "  ",
892                " \tif (keyval == Gdk.Key.Return && _this.search_entry.el.text.length > 0) {",
893                "\t\t_this.forwardSearch(true);",
894                "\t\t",
895                "\t\t",
896                "\t    return true;",
897                "",
898                "\t}    ",
899                "   // print(event.key.keyval)",
900                "   ",
901                "    return false;",
902                "}",
903                ""
904               ]
905              },
906              "xtype" : "EventControllerKey"
907             }
908            ],
909            "listeners" : {
910             "search_changed" : [
911              "( ) => {",
912              "",
913              "_this.search(_this.search_entry.el.text);",
914              "\t _this.search_results.updateResults();",
915              "",
916              "\tGLib.Timeout.add_seconds(1,() => {",
917              "\t\t _this.search_results.updateResults();",
918              "\t\t return false;",
919              "\t });",
920              "}",
921              ""
922             ]
923            },
924            "string name" : "editor-search-entry",
925            "string placeholder_text" : "Press enter to search",
926            "uint search_delay" : 3,
927            "xtype" : "SearchEntry",
928            "| void forwardSearch" : [
929             "(bool change_focus) {",
930             "",
931             "",
932             "\t_this.forwardSearch(change_focus);",
933             "",
934             "/*",
935             "",
936             "\tswitch(_this.windowstate.state) {",
937             "\t\tcase WindowState.State.CODEONLY:",
938             "\t\t//case WindowState.State.CODE:",
939             "\t\t\t// search the code being edited..",
940             "\t\t\t_this.windowstate.code_editor_tab.forwardSearch(change_focus);",
941             "\t\t\t ",
942             "\t\t\tbreak;",
943             "\t\tcase WindowState.State.PREVIEW:",
944             "\t\t\tif (_this.windowstate.file.xtype == \"Gtk\") {",
945             "\t\t\t\t_this.windowstate.window_gladeview.forwardSearch(change_focus);",
946             "\t\t\t} else { ",
947             "\t\t\t\t _this.windowstate.window_rooview.forwardSearch(change_focus);",
948             "\t\t\t}",
949             "\t\t",
950             "\t\t\tbreak;",
951             "\t}",
952             "\t*/",
953             "\t",
954             "}",
955             ""
956            ]
957           },
958           {
959            "$ xns" : "Gtk",
960            "id" : "search_results",
961            "int margin_end" : 4,
962            "int margin_start" : 4,
963            "string label" : "No Results",
964            "xtype" : "Label",
965            "| void updateResults" : [
966             "() {",
967             "\tthis.el.visible = true;",
968             "\t",
969             "\tvar res = _this.searchcontext.get_occurrences_count();",
970             "\tif (res < 0) {",
971             "\t\t_this.search_results.el.label = \"??? Matches\";\t\t",
972             "\t\treturn;",
973             "\t}",
974             "",
975             "\t_this.nextBtn.el.sensitive = false;",
976             "\t_this.backBtn.el.sensitive = false;\t",
977             "",
978             "\tif (res > 0) {",
979             "\t\t_this.search_results.el.label = \"%d Matches\".printf(res);",
980             "\t\t_this.nextBtn.el.sensitive = true;",
981             "\t\t_this.backBtn.el.sensitive = true;",
982             "\t\treturn;",
983             "\t} ",
984             "\t_this.search_results.el.label = \"No Matches\";",
985             "\t",
986             "}"
987            ]
988           },
989           {
990            "$ xns" : "Gtk",
991            "bool always_show_image" : true,
992            "bool sensitive" : false,
993            "id" : "nextBtn",
994            "listeners" : {
995             "clicked" : [
996              "(event) => {",
997              "",
998              "\t_this.forwardSearch(true);",
999              "\t",
1000              "\t ",
1001              "}",
1002              ""
1003             ]
1004            },
1005            "string icon_name" : "go-down",
1006            "xtype" : "Button"
1007           },
1008           {
1009            "$ xns" : "Gtk",
1010            "bool always_show_image" : true,
1011            "bool sensitive" : false,
1012            "id" : "backBtn",
1013            "listeners" : {
1014             "clicked" : [
1015              "(event) => {",
1016              "",
1017              "\t_this.backSearch(true);",
1018              "\t ",
1019              "}",
1020              ""
1021             ]
1022            },
1023            "string icon_name" : "go-up",
1024            "xtype" : "Button"
1025           },
1026           {
1027            "$ xns" : "Gtk",
1028            "bool always_show_arrow" : true,
1029            "bool always_show_image" : true,
1030            "items" : [
1031             {
1032              "$ xns" : "Gtk",
1033              "* prop" : "popover",
1034              "id" : "search_settings",
1035              "items" : [
1036               {
1037                "$ xns" : "Gtk",
1038                "* prop" : "child",
1039                "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
1040                "int spacing" : 0,
1041                "items" : [
1042                 {
1043                  "$ xns" : "Gtk",
1044                  "* init" : [
1045                   "{",
1046                   "\tthis.el.show();",
1047                   "}",
1048                   ""
1049                  ],
1050                  "id" : "case_sensitive",
1051                  "string label" : "Case Sensitive",
1052                  "xtype" : "CheckButton"
1053                 },
1054                 {
1055                  "$ xns" : "Gtk",
1056                  "* init" : [
1057                   "{",
1058                   "\tthis.el.show();",
1059                   "}",
1060                   ""
1061                  ],
1062                  "id" : "regex",
1063                  "string label" : "Regex",
1064                  "xtype" : "CheckButton"
1065                 },
1066                 {
1067                  "$ xns" : "Gtk",
1068                  "id" : "multiline",
1069                  "string label" : "Multi-line (add \\n)",
1070                  "xtype" : "CheckButton"
1071                 }
1072                ],
1073                "xtype" : "Box"
1074               }
1075              ],
1076              "xtype" : "Popover"
1077             }
1078            ],
1079            "string icon_name" : "emblem-system",
1080            "xtype" : "MenuButton"
1081           }
1082          ],
1083          "xtype" : "Box"
1084         }
1085        ],
1086        "xtype" : "Box"
1087       },
1088       {
1089        "$ xns" : "Gtk",
1090        "* prop" : "end_child",
1091        "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
1092        "bool hexpand" : true,
1093        "bool vexpand" : true,
1094        "bool visible" : false,
1095        "id" : "navigation_holder",
1096        "int spacing" : 0,
1097        "int width_request" : 120,
1098        "items" : [
1099         {
1100          "$ xns" : "Gtk",
1101          "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
1102          "int spacing" : 0,
1103          "xtype" : "Box"
1104         },
1105         {
1106          "$ xns" : "Gtk",
1107          "bool hexpand" : true,
1108          "bool vexpand" : true,
1109          "bool visible" : true,
1110          "id" : "navigationwindow",
1111          "items" : [
1112           {
1113            "# int last_selected_line" : "-1",
1114            "$ Gtk.Widget? selected_row" : "null",
1115            "$ xns" : "Gtk",
1116            "* prop" : "child",
1117            "id" : "navigation",
1118            "items" : [
1119             {
1120              "$ xns" : "Gtk",
1121              "bool expand" : true,
1122              "items" : [
1123               {
1124                "$ xns" : "Gtk",
1125                "* prop" : "factory",
1126                "listeners" : {
1127                 "bind" : [
1128                  "(listitem) => {",
1129                  "\t ",
1130                  "\t// GLib.debug(\"listitme is is %s\", ((Gtk.ListItem)listitem).get_type().name());",
1131                  "\t",
1132                  "\t//var expand = (Gtk.TreeExpander) ((Gtk.ListItem)listitem).get_child();",
1133                  "\tvar expand = (Gtk.TreeExpander)  ((Gtk.ListItem)listitem).get_child();",
1134                  "\t ",
1135                  "\t ",
1136                  "\tvar hbox = (Gtk.Box) expand.child;",
1137                  " ",
1138                  "\t",
1139                  "\tvar img = (Gtk.Image) hbox.get_first_child();",
1140                  "\tvar lbl = (Gtk.Label) img.get_next_sibling();",
1141                  "\t",
1142                  "\tvar lr = (Gtk.TreeListRow)((Gtk.ListItem)listitem).get_item();",
1143                  "\tvar sym = (Lsp.DocumentSymbol) lr.get_item();",
1144                  "\t",
1145                  "\tsym.set_data<Gtk.Widget>(\"widget\", expand.get_parent());",
1146                  "\texpand.get_parent().get_parent().set_data<Lsp.DocumentSymbol>(\"symbol\", sym);",
1147                  "\t",
1148                  "\t//GLib.debug(\"save sym on %s\", expand.get_parent().get_parent().get_type().name());",
1149                  "\t",
1150                  "\t//GLib.debug(\"got %d children for %s\" , (int)sym.children.get_n_items(), sym.name);",
1151                  "    ",
1152                  "    expand.set_hide_expander( sym.children.get_n_items()  < 1);",
1153                  " \texpand.set_list_row(lr);",
1154                  " \t//this.in_bind = true;",
1155                  " \t// default is to expand",
1156                  " ",
1157                  " \t//this.in_bind = false;",
1158                  " \t",
1159                  " \tsym.bind_property(\"symbol_icon\",",
1160                  "                    img, \"icon_name\",",
1161                  "                   GLib.BindingFlags.SYNC_CREATE);",
1162                  " \t",
1163                  " \thbox.css_classes = { sym.symbol_icon };",
1164                  " \t",
1165                  " \tsym.bind_property(\"name\",",
1166                  "                    lbl, \"label\",",
1167                  "                   GLib.BindingFlags.SYNC_CREATE);",
1168                  " \t// should be better?- --line no?",
1169                  " \tsym.bind_property(\"tooltip\",",
1170                  "                    lbl, \"tooltip_markup\",",
1171                  "                   GLib.BindingFlags.SYNC_CREATE);",
1172                  " \t// bind image...",
1173                  " \t",
1174                  "}",
1175                  ""
1176                 ],
1177                 "setup" : [
1178                  "(listitem) => {",
1179                  "\t",
1180                  "\tvar expand = new Gtk.TreeExpander();",
1181                  "\t ",
1182                  "\texpand.set_indent_for_depth(true);",
1183                  "\texpand.set_indent_for_icon(true);",
1184                  "\tvar hbox = new Gtk.Box(Gtk.Orientation.HORIZONTAL,0);",
1185                  "\tvar icon = new Gtk.Image();",
1186                  "\tvar lbl = new Gtk.Label(\"\");",
1187                  "\tlbl.use_markup = true;",
1188                  "\tlbl.ellipsize = Pango.EllipsizeMode.END;",
1189                  "\t",
1190                  "\ticon.margin_end = 4;",
1191                  " \tlbl.justify = Gtk.Justification.LEFT;",
1192                  " \tlbl.xalign = 0;",
1193                  "",
1194                  "//\tlistitem.activatable = true; ??",
1195                  "\t",
1196                  "\thbox.append(icon);",
1197                  "\thbox.append(lbl);",
1198                  "\texpand.set_child(hbox);",
1199                  "\t((Gtk.ListItem)listitem).set_child(expand);",
1200                  "\t",
1201                  "}",
1202                  ""
1203                 ]
1204                },
1205                "xtype" : "SignalListItemFactory"
1206               }
1207              ],
1208              "string title" : "Code Navigation",
1209              "xtype" : "ColumnViewColumn"
1210             },
1211             {
1212              "$ xns" : "Gtk",
1213              "* prop" : "model",
1214              "id" : "navigationselmodel",
1215              "items" : [
1216               {
1217                "$ xns" : "Gtk",
1218                "* prop" : "model",
1219                "id" : "navigationsort",
1220                "items" : [
1221                 {
1222                  "$ Gtk.TreeListModelCreateModelFunc create_func" : [
1223                   "(item) => {",
1224                   " ",
1225                   "\treturn ((Lsp.DocumentSymbol)item).children;",
1226                   "}",
1227                   ""
1228                  ],
1229                  "$ xns" : "Gtk",
1230                  "* prop" : "model",
1231                  "bool autoexpand" : true,
1232                  "bool passthrough" : false,
1233                  "items" : [
1234                   {
1235                    "$ GLib.Type item_type" : "typeof(Lsp.DocumentSymbol)",
1236                    "$ xns" : "GLib",
1237                    "* prop" : "root",
1238                    "id" : "navliststore",
1239                    "xtype" : "ListStore",
1240                    "| Lsp.DocumentSymbol? symbolAtLine" : [
1241                     "(uint line, uint chr) {",
1242                     " ",
1243                     "\t",
1244                     "\tfor(var i = 0; i < this.el.get_n_items();i++) {",
1245                     "\t\tvar el = (Lsp.DocumentSymbol)this.el.get_item(i);",
1246                     "\t\t//GLib.debug(\"Check sym %s : %d-%d\",",
1247                     "\t\t//\tel.name , (int)el.range.start.line,",
1248                     "\t\t//\t(int)el.range.end.line",
1249                     "\t\t//);",
1250                     "\t\tvar ret = el.containsLine(line,chr);",
1251                     "\t\tif (ret != null) {",
1252                     "\t\t\treturn ret;",
1253                     "\t\t}",
1254                     "\t\t",
1255                     "\t}",
1256                     "\t",
1257                     "\treturn null;",
1258                     "}"
1259                    ]
1260                   }
1261                  ],
1262                  "listeners" : {
1263                   "items_changed" : [
1264                    "(position, removed, added) => {",
1265                    "\tGLib.debug(\"tree item changed %d , %d , %d\",(int) position, (int)removed, (int) added);",
1266                    "\t if (added < 1) { ",
1267                    "\t \treturn;",
1268                    " \t}",
1269                    "\t//var sym = (Lsp.DocumentSymbol) this.el.get_item(position);",
1270                    "\tvar row = this.el.get_row(position);",
1271                    "\t",
1272                    "\tGLib.debug(\"got %s\", row.get_item().get_type().name());",
1273                    "\t",
1274                    "",
1275                    "}",
1276                    ""
1277                   ]
1278                  },
1279                  "xtype" : "TreeListModel"
1280                 },
1281                 {
1282                  "$ xns" : "Gtk",
1283                  "* prop" : "sorter",
1284                  "items" : [
1285                   {
1286                    "$ xns" : "Gtk",
1287                    "* prop" : "sorter",
1288                    "items" : [
1289                     {
1290                      "$ GLib.Type this_type" : "typeof(Lsp.DocumentSymbol)",
1291                      "$ xns" : "Gtk",
1292                      "* prop" : "expression",
1293                      "string property_name" : "sort_key",
1294                      "xtype" : "PropertyExpression"
1295                     }
1296                    ],
1297                    "xtype" : "StringSorter"
1298                   }
1299                  ],
1300                  "xtype" : "TreeListRowSorter"
1301                 }
1302                ],
1303                "xtype" : "SortListModel",
1304                "| Lsp.DocumentSymbol? getSymbolAt" : [
1305                 "(uint row) {",
1306                 "",
1307                 "   var tr = (Gtk.TreeListRow)this.el.get_item(row);",
1308                 "   ",
1309                 "   var a = tr.get_item();;   ",
1310                 "   GLib.debug(\"get_item (2) = %s\", a.get_type().name());",
1311                 "  \t",
1312                 "   ",
1313                 "   return (Lsp.DocumentSymbol)tr.get_item();",
1314                 "\t ",
1315                 "}"
1316                ],
1317                "| int getRowFromSymbol" : [
1318                 "(Lsp.DocumentSymbol sym) {",
1319                 "",
1320                 "\tfor (var i=0;i < this.el.get_n_items(); i++) {",
1321                 "\t\tvar tr = (Gtk.TreeListRow)this.el.get_item(i);",
1322                 "\t   ",
1323                 "\t\tif (sym.equals( (Lsp.DocumentSymbol)tr.get_item())) {",
1324                 "\t\t\treturn i;",
1325                 "\t\t}",
1326                 "\t}",
1327                 "   \treturn -1;",
1328                 "}"
1329                ],
1330                "| void collapseOnLoad" : [
1331                 "() {",
1332                 "\tfor (var i=0;i < this.el.get_n_items(); i++) {",
1333                 "\t\tvar tr = (Gtk.TreeListRow)this.el.get_item(i);",
1334                 "\t\tvar sym =  (Lsp.DocumentSymbol)tr.get_item();",
1335                 "\t\tswitch (sym.kind) {",
1336                 "\t \t\tcase Lsp.SymbolKind.Enum: ",
1337                 "\t \t\t\ttr.expanded = false;",
1338                 "\t \t\t\tbreak;",
1339                 "\t\t\tdefault:",
1340                 "\t\t\t\t//tr.expanded = true;",
1341                 "\t\t\t\tbreak;",
1342                 "\t\t}",
1343                 "\t}",
1344                 " ",
1345                 "\t",
1346                 "",
1347                 "",
1348                 "}"
1349                ]
1350               }
1351              ],
1352              "xtype" : "NoSelection"
1353             },
1354             {
1355              "$ xns" : "Gtk",
1356              "listeners" : {
1357               "pressed" : [
1358                "(n_press, x, y) => {",
1359                "\tstring pos;",
1360                "  \tvar row = _this.navigation.getRowWidgetAt(x,y, out pos );",
1361                "",
1362                "    if (row == null) {",
1363                "\t    GLib.debug(\"no row selected items\");",
1364                "\t    return;",
1365                "    }",
1366                "\tGLib.debug(\"got click on %s\", row.get_type().name());    ",
1367                "    //Lsp.DocumentSymbol",
1368                "    var sym =  row.get_data<Lsp.DocumentSymbol>(\"symbol\");",
1369                "    if (sym == null) {",
1370                "    \treturn;",
1371                "\t}",
1372                "\t/*",
1373                "\t \"range\" : {",
1374                "              \"start\" : {",
1375                "                \"line\" : 1410,",
1376                "                \"character\" : 8",
1377                "              },",
1378                "              \"end\" : {",
1379                "                \"line\" : 1410,",
1380                "                \"character\" : 39",
1381                "              }",
1382                "            },",
1383                "        */",
1384                "     GLib.debug(\"goto line %d\",   (int)sym.range.start.line); ",
1385                "    _this.scroll_to_line((int)sym.range.start.line);",
1386                "    Gtk.TextIter iter;",
1387                "    _this.buffer.el.get_iter_at_line_offset(out iter, ",
1388                "    \t(int)sym.range.start.line,",
1389                "    \t(int)sym.range.start.character",
1390                "\t);",
1391                "    _this.buffer.el.place_cursor(iter);",
1392                "\t",
1393                "}"
1394               ]
1395              },
1396              "xtype" : "GestureClick"
1397             }
1398            ],
1399            "string name" : "editor-navigation",
1400            "xtype" : "ColumnView",
1401            "| Gtk.Widget? getRowWidgetAt" : [
1402             "(double x,  double  y, out string pos) {",
1403             "",
1404             "\tpos = \"\";",
1405             "\tvar w = this.el.pick(x, y, Gtk.PickFlags.DEFAULT);",
1406             "\t//GLib.debug(\"got widget %s\", w == null ? \"nothing\" : w.get_type().name());",
1407             "\tif (w == null) {",
1408             "\t\treturn null;",
1409             "\t}",
1410             "\t",
1411             "\tvar row= w.get_ancestor(GLib.Type.from_name(\"GtkColumnViewRowWidget\"));",
1412             "\tif (row == null) {",
1413             "\t\treturn null;",
1414             "\t}",
1415             "\t",
1416             "\t//GLib.debug(\"got colview %s\", row == null ? \"nothing\" : row.get_type().name());",
1417             "\t ",
1418             " ",
1419             "\t",
1420             "\t//GLib.debug(\"row number is %d\", rn);",
1421             "\t//GLib.debug(\"click %d, %d\", (int)x, (int)y);",
1422             "\t// above or belw",
1423             "\tGraphene.Rect  bounds;",
1424             "\trow.compute_bounds(this.el, out bounds);",
1425             "\t//GLib.debug(\"click x=%d, y=%d, w=%d, h=%d\", ",
1426             "\t//\t(int)bounds.get_x(), (int)bounds.get_y(),",
1427             "\t//\t(int)bounds.get_width(), (int)bounds.get_height()",
1428             "\t//\t);",
1429             "\tvar ypos = y - bounds.get_y();",
1430             "\t//GLib.debug(\"rel ypos = %d\", (int)ypos);\t",
1431             "\tvar rpos = 100.0 * (ypos / bounds.get_height());",
1432             "\t//GLib.debug(\"rel pos = %d %%\", (int)rpos);",
1433             "\tpos = \"over\";",
1434             "\t",
1435             "\tif (rpos > 80) {",
1436             "\t\tpos = \"below\";",
1437             "\t} else if (rpos < 20) {",
1438             "\t\tpos = \"above\";",
1439             "\t} ",
1440             "\treturn row;",
1441             " }"
1442            ],
1443            "| int getRowAt" : [
1444             "(double x,  double  y, out string pos) {",
1445             "",
1446             "\tpos = \"\";",
1447             "\tvar w = this.el.pick(x, y, Gtk.PickFlags.DEFAULT);",
1448             "\t//GLib.debug(\"got widget %s\", w == null ? \"nothing\" : w.get_type().name());",
1449             "\tif (w == null) {",
1450             "\t\treturn -1;",
1451             "\t}",
1452             "\t",
1453             "\tvar row= w.get_ancestor(GLib.Type.from_name(\"GtkColumnViewRowWidget\"));",
1454             "\tif (row == null) {",
1455             "\t\treturn -1;",
1456             "\t}",
1457             "\t",
1458             "\t//GLib.debug(\"got colview %s\", row == null ? \"nothing\" : row.get_type().name());",
1459             "\t ",
1460             "\tvar rn = 0;",
1461             "\tvar cr = row;",
1462             "\t ",
1463             "\twhile (cr.get_prev_sibling() != null) {",
1464             "\t\trn++;",
1465             "\t\tcr = cr.get_prev_sibling();",
1466             "\t}",
1467             "\t",
1468             "\t//GLib.debug(\"row number is %d\", rn);",
1469             "\t//GLib.debug(\"click %d, %d\", (int)x, (int)y);",
1470             "\t// above or belw",
1471             "\tGraphene.Rect  bounds;",
1472             "\trow.compute_bounds(this.el, out bounds);",
1473             "\t//GLib.debug(\"click x=%d, y=%d, w=%d, h=%d\", ",
1474             "\t//\t(int)bounds.get_x(), (int)bounds.get_y(),",
1475             "\t//\t(int)bounds.get_width(), (int)bounds.get_height()",
1476             "\t//\t);",
1477             "\tvar ypos = y - bounds.get_y();",
1478             "\t//GLib.debug(\"rel ypos = %d\", (int)ypos);\t",
1479             "\tvar rpos = 100.0 * (ypos / bounds.get_height());",
1480             "\t//GLib.debug(\"rel pos = %d %%\", (int)rpos);",
1481             "\tpos = \"over\";",
1482             "\t",
1483             "\tif (rpos > 80) {",
1484             "\t\tpos = \"below\";",
1485             "\t} else if (rpos < 20) {",
1486             "\t\tpos = \"above\";",
1487             "\t} ",
1488             "\treturn rn;",
1489             " }"
1490            ],
1491            "| void show" : [
1492             "(Gee.ArrayList<Lsp.DocumentSymbol> syms) {",
1493             "\t",
1494             "\tif (!_this.navigation_holder.el.visible) {",
1495             "\t\t_this.navigation_holder.el.show();",
1496             "\t\t_this.paned.el.position  = ",
1497             "\t\t\t_this.paned.el.get_width() - 200;",
1498             "\t} ",
1499             "\t//_this.navliststore.el.remove_all();",
1500             "\t",
1501             "\t",
1502             "\tvar ls  = new GLib.ListStore(typeof(Lsp.DocumentSymbol));",
1503             "\t",
1504             "\tforeach(var sym in syms) {",
1505             "\t\tls.append(sym);",
1506             "\t}",
1507             "\t// if syms updated is empty, but we already have one..",
1508             "\tif (_this.navliststore.el.get_n_items() > 0 && ls.get_n_items() < 1) {",
1509             "\t\treturn;",
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 }