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