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