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