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