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