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