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