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